Why don't RACCommand
's execution signals complete? Consider the following example:
RACCommand *command = [[RACCommand alloc] initWithSignalBlock:^ RACSignal * (id value) {
return [RACSignal createSignal:^ RACDisposable * (id<RACSubscriber> subscriber) {
[subscriber sendNext:value];
[subscriber sendCompleted];
return nil;
}];
}];
[command.executionSignals.switchToLatest subscribeNext:^(id value) {
NSLog(@"next: %@", value); // logs "next: foo"
} completed:^{
NSLog(@"completed"); // never executes
}];
[command execute:@"foo"];
Not to be mistaken with the executionSignals
signal of signals.
-switchToLatest
does not complete until the signal-of-signals completes. You'd need to use -materialize
or -concat:
on the inner signals to identify a completion event.
I looked at the documentation of everything except the one of -switchToLatest
.
Thanks for the quick reply. You guys rock. :wink:
Hi, guys
I encounter the same problem,
How could I get the inner signal of a command?
thanks
My I get a sample code ?
thanks
[[command.executionSignals
map:^(RACSignal *execution) {
return [execution doCompleted:^{
// something
}];
}]
switchToLatest]
Most helpful comment