iosreactive-cocoaracsignal

Why returned from flattenMap empty does not trigger subscribeCompleted


I transform any new value from signal with flattenMap, and I want to stop process based on some condition, not with error, but with completed state. Mentioned below code does not allow to do this. It just filters some value. How can I complete from flattenMap?

RACSignal* anySignal = //
[ [ anySignal
 flattenMap: ^(id _)
 {
    return [ RACSignal empty ];
 } ]
subscribeCompleted:
^{
   NSLog(@"Not Called");
}];

Solution

  • -flattenMap: doesn't complete until all relevant signals complete, meaning the signal that -flattenMap: is called on, as well as the signals being returned from the map block. To complete the signal, check out -takeUntilBlock: and -takeWhileBlock:.