1
我對RACCommand
的配置機制有點困惑。我想手動處理執行信號的訂閱,但僅在sendCompleted
事件後調用disposableBlock
。這是我真正的任務的問題,希望有人能幫助我。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");
}];
}];
}