1
RACCommand
の処理メカニズムについて少し混乱しています。私は手動で実行信号のサブスクリプションを処分したいが、disposableBlock
はsendCompleted
イベントの後にのみ呼び出す。それは私の本当の仕事の問題です。誰かが私を助けてくれることを願っています。RACCommand - 実行信号を処理する
- (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");
}];
}];
}