I'm sure there's an easier way? Or that it already exists?
+ (RACSignal *)totallyCombinedSignalOfSignals:(NSArray *)signals
{
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
RACCompoundDisposable *compoundDisposable = [RACCompoundDisposable compoundDisposable];
for(RACSignal *signal in signals)
{
RACDisposable *disposable = [signal subscribe:subscriber];
[compoundDisposable addDisposable:disposable];
}
return compoundDisposable;
}];
}
Usecase
/// Finite signal which either sends completed or error
- (RACSignal *)signalCanRenderPage
{
return [[self class] totallyCombinedSignalOfSignals:
@[[self finiteSignalDocumentReady], // sends completed
[self finiteSignalTimeOutWithInterval:20], // sends error
[self finiteSignalDocumentNeedsToBeReloaded]] // sends error
];
}
- (RACSignal *)signalRenderPageWithJSONString:(NSString *)pageJSON
assetsBaseUrl:(NSString *)assetsBaseUrl
{
@weakify(self);
const NSTimeInterval timeOutInterval = 20;
return [[self signalCanRenderPage] then:^RACSignal *{
@strongify(self);
RACSignal *signal = ...;
return signal;
}];
}
No, there isn't currently an operator that behaves that way. It's like a cross between +merge:
and +zip:
.