Can I combine the RAC signals but still get each error separately?
Update:
Instead:
RACSignal * mergedItemsSignals = [RACSignal merge:itemSignalsArray];
create a new signal like this:
RACSignal * mergedItemsSignals = [RACSignal merge:[itemSignalsArray.rac_sequence map:^id(RACSignal * signal) {
return [signal materialize];
}]];
And when you subscribe, you expect RACEvents
that you can distinguish using [RACEvent eventType]
.
With an array of signals, I want to be able to handle each next
and every one individually error
. But I am struggling to find the right operator. So far, the right choice is
merge
: Returns a signal that goes through the values from each of the given signals and dispatches completed
when they all complete. If any signal sends an error, the returned signal dispatches immediately error
.
So, it seems to me that I need something like this. I want to get all the errors, but the unified signal should continue to work and not end up at the first.
I also tried using 'combLatest', but these are only forward events where each signal has sent something and I want to start forwarding as quickly as possible for each signal.
Hope this is clear enough that someone can point me in the right direction. Thanks in advance!
source to share
The signal can only be one time, so you need a way to convert these error
to next
s. Fortunately, materialize
it does just that - given a signal, it signals events from that signal. Then you can split this into two signals, for errors and subsequent ones, or just process them in one block.
So you can take a list of signals, map materialize
, and then concatenate the resulting displayed signals.
- (RACSignal *)mergeEvents:(NSArray *)signals {
return [RACSignal merge:[signals.rac_sequence map:^(RACSignal *signal) {
return [signal materialize];
}]];
}
source to share