标签:csu div span ext pos ber class str code
-(void)_test6{ RACSignal *signal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { [subscriber sendNext:@"first value"]; [subscriber sendNext:@"second value"]; [subscriber sendNext:@"third value"]; [subscriber sendCompleted]; return nil; }]; RACSignal *bindSignal = [signal bind:^RACSignalBindBlock{ return ^RACSignal *(id value, BOOL *stop) { NSString *oValue = value; if ([oValue isEqualToString:@"first value"]) { return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { [subscriber sendNext:@"first value bind after"]; [subscriber sendCompleted]; return nil; }]; } if ([oValue isEqualToString:@"second value"]) { *stop = YES; return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { [subscriber sendNext:@"second value bind after"]; [subscriber sendCompleted]; return nil; }]; } if ([oValue isEqualToString:@"third value"]) { return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { [subscriber sendNext:@"third value bind after"]; [subscriber sendCompleted]; return nil; }]; } return nil; }; }]; [bindSignal subscribeNext:^(id _Nullable x) { NSLog(@"x====%@",x); }]; }
再来一个例子: -(void)_test7{ //1.创建信号 RACSubject * subject = [RACSubject subject]; //2.绑定信号 RACSignal * bindSignal = [subject bind:^RACSignalBindBlock _Nonnull{ return ^RACSignal * (id value, BOOL *stop){ NSLog(@"%@",value); return [RACReturnSignal return:[NSString stringWithFormat:@"一顿操作猛如虎 %@",value]]; }; }]; //3.订阅信号 [bindSignal subscribeNext:^(id _Nullable x) { NSLog(@"绑定接收到!! %@",x); }]; //4.发送 [subject sendNext:@"发送原始的数据"]; }
标签:csu div span ext pos ber class str code
原文地址:https://www.cnblogs.com/liuw-flexi/p/10805828.html