Reputation: 6982
I have a problem using flattenMap
method of RACSignal
- the block never gets called. If I subscribeNext
to the same signal, it works just fine, the problem is only with flattenMap
.
Here's what works fine
[[self.aSignal combineLatestWith:self.otherSignal] subscribeNext:^(RACTuple *tuple) {
// gets called just fine
}];
And here's what doesn't work:
self.yetAnotherSignal = [[self.aSignal combineLatestWith:self.otherSignal] flattenMap:^RACStream *(RACTuple *tuple) {
// never gets called
return returnSignal;
}];
Am I missing something? Or do I misunderstand how flattenMap
works?
Upvotes: 0
Views: 50
Reputation: 3357
It seems like you're missing just one little bit: (at least in your snippet) no one is subscribing to your new signal!
You're constructing a new signal (self.yetAnotherSignal
) from self.aSignal
and self.otherSignal
via combineLatest
and flattenMap
.
But that new signal, as well as any operators in the chain, do not actually do any work until it is subscribed in some form, the simplest form being via subscribeNext
just as you did in your first snippet.
That is not just the case with flattenMap
, its the same with any operation, e.g. combineLatestWith
in your first example would not do anything if you would not subscribe to it. The same goes for map
, filter
, ... you name it.
Upvotes: 1