美文网首页
深入理解RACSignal相关operation

深入理解RACSignal相关operation

作者: 乐客乐活 | 来源:发表于2016-10-19 23:06 被阅读0次
    - (RACSignal *)merge:(RACSignal *)signal {
        return [RACSignal
                merge:@[ self, signal ]];      //(1)
    }
    + (RACSignal *)merge:(id<NSFastEnumeration>)signals {
        NSMutableArray *copiedSignals = [[NSMutableArray alloc] init];
        for (RACSignal *signal in signals) {
            [copiedSignals addObject:signal];     //(2)
        }
        return [[RACSignal
                  createSignal:^ RACDisposable * (id<RACSubscriber> subscriber) {   //(3)
                      for (RACSignal *signal in copiedSignals) {
                          [subscriber sendNext:signal];             //(4)
                      }
                      [subscriber sendCompleted];
                      return nil;
                  }]flatten];                 //(5)
    }
    

    相关文章

      网友评论

          本文标题:深入理解RACSignal相关operation

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