The answer was in RACReplaySubject , which AFNetworking uses to migrate its asynchronous requests.
self.gitHubCommand = [RACCommand command]; self.gitHubSignals = [self.gitHubCommand addSignalBlock:^RACSignal *(id value) { RACReplaySubject *subject = [RACReplaySubject subject]; [engine teamsInOrganization:kOrganizationName withSuccess:^(id result) { for (NSDictionary *team in result) { [subject sendNext:team]; } [subject sendCompleted]; } failure:^(NSError *error) { [subject sendError:error]; }]; return subject; }];
Since addSignalBlock: returns a signal of signals, we need to subscribe to the next signal that it emits.
[self.gitHubSignals subscribeNext:^(id signal) { [signal subscribeNext:^(NSDictionary *team) { NSInteger teamID = [[team valueForKey:@"id"] intValue]; NSLog(@"Team ID: %lu", teamID); }]; }];
Finally, the addSignalBlock: block addSignalBlock: not executed until the command that I succeeded is executed:
[self.gitHubCommand execute:[NSNull null]];
Ash furrow
source share