Reputation: 5222
I am using Reactive Cocoa to merge & collect multiple network requests together (as RACSignals) like so:
[[[RACSignal merge:requestSignals] collect] subscribeNext:^(NSArray *results){...}
Each individual RACSignal is created like so:
- (RACSignal *)signalForMyRequest { RACSignal *signal =
[RACSignal createSignal:^RACDisposable
(id<RACSubscriber> subscriber) {
NSURLSessionDataTask *task = [self myRequest success:nil failure:nil];
return [RACDisposable disposableWithBlock:^{
[task cancel];
}];
}];
return signal;
}
This all works fine. My question is this: is there a way to cancel the actual request (i.e. the NSURLSessionDataTask
) inside of an individual RAC signal? I am using a subscribeNext:
block on the merged signal, which returns a RACDisposable
- which I can dispose, but that applies to the entire merge operation rather than an individual signal. I was looking at things like takeUntil:
but this is described as "releasing the signal" and I'm not certain if that will in turn cancel the request it contains or not. Any help is appreciated.
Upvotes: 2
Views: 175