深入理解RACSignal相关operation

- (RACSignal *)merge:(RACSignal *)signal {
    return [RACSignal
            merge:@[ self, signal ]];      //(1)
}
+ (RACSignal *)merge:(id)signals {
    NSMutableArray *copiedSignals = [[NSMutableArray alloc] init];
    for (RACSignal *signal in signals) {
        [copiedSignals addObject:signal];     //(2)
    }
    return [[RACSignal
              createSignal:^ RACDisposable * (id subscriber) {   //(3)
                  for (RACSignal *signal in copiedSignals) {
                      [subscriber sendNext:signal];             //(4)
                  }
                  [subscriber sendCompleted];
                  return nil;
              }]flatten];                 //(5)
}

你可能感兴趣的:(深入理解RACSignal相关operation)