Skip to content

Instantly share code, notes, and snippets.

@Coneko
Created November 27, 2012 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Coneko/4156996 to your computer and use it in GitHub Desktop.
Save Coneko/4156996 to your computer and use it in GitHub Desktop.
+combineLatest:reduce: serialization issue.
for(id<RACSignal> signal in signals) {
RACDisposable *disposable = [signal subscribe:[RACSubscriber subscriberWithNext:^(id x) {
@synchronized(lastValues) {
[lastValues setObject:x ? : [RACTupleNil tupleNil] forKey:[NSString stringWithFormat:@"%p", signal]];
if(lastValues.count == signals.count) {
NSMutableArray *orderedValues = [NSMutableArray arrayWithCapacity:signals.count];
for(id<RACSignal> o in signals) {
[orderedValues addObject:[lastValues objectForKey:[NSString stringWithFormat:@"%p", o]]];
}
if (reduceBlock == NULL) {
[subscriber sendNext:[RACTuple tupleWithObjectsFromArray:orderedValues]];
} else {
[subscriber sendNext:[RACBlockTrampoline invokeBlock:reduceBlock withArguments:orderedValues]];
}
}
}
} error:^(NSError *error) {
[subscriber sendError:error];
} completed:^{
@synchronized(completedSignals) {
[completedSignals addObject:signal];
if(completedSignals.count == signals.count) {
[subscriber sendCompleted];
}
}
}]];
if(disposable != nil) {
[disposables addObject:disposable];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment