Created
April 20, 2013 15:07
-
-
Save brynbellomy/5426288 to your computer and use it in GitHub Desktop.
RAC: async request factory method returning a RACSignal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (RACSignal *)enqueueRequestWithMethod:(NSString *)method | |
| path:(NSString *)path | |
| parameters:(NSDictionary *)parameters | |
| { | |
| RACReplaySubject *subject = [RACReplaySubject subject]; | |
| NSURLRequest *request = [self requestWithMethod:method path:path parameters:parameters]; | |
| AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
| [subject sendNext:responseObject]; | |
| [subject sendCompleted]; | |
| } failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
| [subject sendError:error]; | |
| }]; | |
| [self enqueueHTTPRequestOperation:operation]; | |
| return subject; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment