Given a method that returns an array of objects, how could you create a sequence that would be populated only with the results of this method when using it?
- (NSArray *) methodA { ... }
- (RACSequence *) methodB {
return [self methodA].rac_sequence;
}
I am wondering if it is possible to avoid the execution of method A, unless this sequence is used, but still returns the sequence from method B, in order to pass it, I decided to use it.
Update
I managed to achieve the desired behavior using a signal instead of a sequence.
- (RACSignal *)methodB {
RACSignal *racSignal = [RACSignal defer:^RACSignal * {
return [self methodA].rac_sequence.signal;
}];
return racSignal;
}
Now method A is called only when subscribing to a signal. Why is there no similar concept for delaying sequences?
source
share