Created
November 27, 2012 21:03
-
-
Save Coneko/4156996 to your computer and use it in GitHub Desktop.
+combineLatest:reduce: serialization issue.
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
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