//RACMulticastConnection 多次订阅同一个信号
RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id _Nonnull subscriber) {
NSLog(@"发送请求");
[subscriber sendNext:@"请求到数据"];
return nil;
}];
//不敢订阅多少次信号,就之后请求一次信号
//将信号转成连接类
RACMulticastConnection *connection = [signal publish];
//1
[connection.signal subscribeNext:^(id _Nullable x) {
NSLog(@"A:%@",x);
}];
//2
[connection.signal subscribeNext:^(id _Nullable x) {
NSLog(@"B:%@",x);
}];
[connection connect];//连接 ,连接的时候才有请求数据,否则没有
网友评论