Igor Palaguta
Igor Palaguta

Reputation: 3579

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");
}];

Upvotes: 1

Views: 252

Answers (1)

Dave Lee
Dave Lee

Reputation: 6489

-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:.

Upvotes: 5

Related Questions