美文网首页
RAC :RACMulticastConnection 多次订阅

RAC :RACMulticastConnection 多次订阅

作者: NextStepPeng | 来源:发表于2018-01-11 16:15 被阅读0次

//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];//连接 ,连接的时候才有请求数据,否则没有

相关文章

网友评论

      本文标题:RAC :RACMulticastConnection 多次订阅

      本文链接:https://www.haomeiwen.com/subject/fvctoxtx.html