Skip to content

Instantly share code, notes, and snippets.

@ReDetection
Created August 11, 2014 08:05
Show Gist options
  • Save ReDetection/f4a157517eafff978ede to your computer and use it in GitHub Desktop.
Save ReDetection/f4a157517eafff978ede to your computer and use it in GitHub Desktop.
NSString *urlString = @"https://api.mongolab.com/api/1/databases/todo/collections/tasks/";
NSURL *url = [NSURL URLWithString:urlString];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *key = @{@"apiKey": @"MWxF-8RKg5wx4oLLDDDZa5Mdd01to7zV"};
void (^logMessage)(RACTuple *) = ^(RACTuple * x) {
AFHTTPRequestOperation *operation = x.first;
NSData *data = x.second;
NSString *message = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"path: %@, message %@", operation.request.URL.lastPathComponent, message);
};
RAC(self.label, text) = [[[RACSignal
merge:@[
[[client rac_getPath:@"53594736e4b0ddd860afc445" parameters:key] doNext:logMessage],
[[client rac_getPath:@"535946a7e4b0ddd860afc364" parameters:key] doNext:logMessage],
[[client rac_getPath:@"53594606e4b094f2b232b3a2" parameters:key] doNext:logMessage],
[[_button rac_signalForControlEvents:UIControlEventTouchUpInside] take:1],
]] scanWithStart:@0 combine:^id(NSNumber *count, id next) {
return @(count.integerValue + 1);
}] map:^NSString *(NSNumber *value) {
return [NSString stringWithFormat:@"%@ событий получено", value];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment