Reactivecocoa: Why don't RACCommand's execution signals complete?

Created on 3 Feb 2015  路  5Comments  路  Source: ReactiveCocoa/ReactiveCocoa

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.

question

Most helpful comment

[[command.executionSignals
    map:^(RACSignal *execution) {
        return [execution doCompleted:^{
            // something
        }];
    }]
    switchToLatest]

All 5 comments

-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]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdiep picture mdiep  路  5Comments

toddbluhm picture toddbluhm  路  5Comments

simonxcheng picture simonxcheng  路  6Comments

v-silin picture v-silin  路  4Comments

samidalouche picture samidalouche  路  6Comments