Skip to content

Instantly share code, notes, and snippets.

@kyleclegg
Last active August 29, 2015 14:03
Show Gist options
  • Save kyleclegg/458622a8bd5a1005fb3f to your computer and use it in GitHub Desktop.
Save kyleclegg/458622a8bd5a1005fb3f to your computer and use it in GitHub Desktop.
Code sample taken from http://www.techsfo.com/blog/2013/08/managing-nested-asynchronous-callbacks-in-objective-c-using-reactive-cocoa/. signalGetNetworkStep makes an async call to an endpoint.
__weak id weakSelf = self;
[[[[[self signalGetNetworkStep1] flattenMap:^RACStream*(id *x) {
// perform your custom business logic
return [weakSelf signalGetNetworkStep2:x];
}] flattenMap:^RACStream*(id *y) {
// perform additional business logic
return [weakSelf signalGetNetworkStep3:y];
}] flattenMap:^RACStream*(id *z) {
// more business logic
return [weakSelf signalGetNetworkStep4:z];
}] subscribeNext:^(id*w) {
// last business logic
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment