I have a little confused about dispose mechanism of RACCommand
. I want to dispose subscription of executing signal manually, but disposableBlock
invokes only after sendCompleted
event. It's a problem of my real task, hope someone can help me.
- (void)test {
RACCommand *rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
return [self signal];
}];
RACDisposable *rac_dispose = [[rac_command execute:nil] subscribeNext:^(id x) {}];
[rac_dispose dispose];
}
- (RACSignal *)signal {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[subscriber sendNext:nil];
[subscriber sendCompleted];
});
return [RACDisposable disposableWithBlock:^{
NSLog(@"dispose block");
}];
}];
}