Combine signals in ReactiveCocoa to a new one that fires when all change

一笑奈何 提交于 2019-11-30 07:28:24

Instead of +combineLatest:reduce:, you want +zip:reduce:. Zip requires that all the signals change before reducing and sending a new value.

Since you don't actually care about the values from the timer, -sample: may do what you want:

[[gestureSignal
    sample:updateEventSignal]
    subscribeNext:^(id tap) {
        NSLog(@"Tapped [%@]", tap);
    }];

This will forward the latest value from gestureSignal whenever updateEventSignal fires.

   [[[[RACSignal zip:@[RACObserve(self, minimum), RACObserve(self, maximum), 
RACObserve(self, average)]] skip:1] reduceEach:^id{
            return nil;
        }] subscribeNext:^(id x) {
            [self buildView]; //called once, while all three values were changed.
        }];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!