// 信号高阶操作
// 通过信号转换
// 升阶 value转signal
// 降阶 signal转value
升阶:
// 实际应用场景——升阶 value转signal
// 蛋疼的订阅方法
RACSignal *signalA = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
[subscriber sendNext:@1];
[subscriber sendNext:@2];
[subscriber sendNext:@3];
[subscriber sendNext:@4];
[subscriber sendNext:@5];
[subscriber sendCompleted];
return [RACDisposable disposableWithBlock:^{
NSLog(@"signalA1完成");
}];
}];
RACSignal *signalB = [signalA map:^id(id value) {
return [RACSignal return:value];
}];
[[signalB subscribeNext:^(RACSignal *x) {
[x subscribeNext:^(id x) {
NSLog(@"subscribeNext:%@",x);
}];
}] dispose];
2021-04-15 16:32:26.148228+0800 XXXXXX[3834:1102013] [DYMTLInitPlatform] platform initialization successful
2021-04-15 16:32:27.193424+0800 XXXXXX[3834:1101906] subscribeNext:1
2021-04-15 16:32:27.193515+0800 XXXXXX[3834:1101906] subscribeNext:2
2021-04-15 16:32:27.193551+0800 XXXXXX[3834:1101906] subscribeNext:3
2021-04-15 16:32:27.193574+0800 XXXXXX[3834:1101906] subscribeNext:4
2021-04-15 16:32:27.193595+0800 XXXXXX[3834:1101906] subscribeNext:5
2021-04-15 16:32:27.194864+0800 XXXXXX[3834:1101906] signalA1完成
网友评论