我确定有一种更简单的方法吗?或者它已经存在?
+ (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;
}];
}
答案 0 :(得分:1)
不,目前没有一个运营商表现那样。这就像+merge:
和+zip:
之间的交叉。