标签:
- (void)timeout { RACSignal *signal = [[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { return nil; }] timeout:1 onScheduler:[RACScheduler currentScheduler]]; [signal subscribeNext:^(id x) { NSLog(@"%@", x); } error:^(NSError *error) { //1秒后会自动调用 NSLog(@"error = %@", error); }]; /*结果:error = Error Domain=RACSignalErrorDomain Code=1 "(null)"*/ }
- (void)interval { [[RACSignal interval:1 onScheduler:[RACScheduler currentScheduler]] subscribeNext:^(id x) { NSLog(@"%@", x); }]; }
- (void)delay { [[[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { [subscriber sendNext:@1]; return nil; }] delay:2] subscribeNext:^(id x) { NSLog(@"%@", x); }]; }
标签:
原文地址:http://www.cnblogs.com/HMJ-29/p/4944007.html