Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why don't RACCommand's execution signals complete? #1726

Closed
akashivskyy opened this issue Feb 3, 2015 · 5 comments
Closed

Why don't RACCommand's execution signals complete? #1726

akashivskyy opened this issue Feb 3, 2015 · 5 comments
Labels

Comments

@akashivskyy
Copy link

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.

@jspahrsummers
Copy link
Member

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

@akashivskyy
Copy link
Author

I looked at the documentation of everything except the one of -switchToLatest.

Thanks for the quick reply. You guys rock. 😉

@taojigu
Copy link

taojigu commented Jul 16, 2016

Hi, guys

I encounter the same problem,
How could I get the inner signal of a command?

thanks

@taojigu
Copy link

taojigu commented Jul 16, 2016

My I get a sample code ?

thanks

@mdiep
Copy link
Contributor

mdiep commented Jul 17, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants