2
我想在self.personsArray
被更新以執行各種任務如下:如何保證ReactiveCocoa中訂閱者消息的順序?
- (void)viewDidAppear:(BOOL)animated
{
@weakify(self)
[RACObserve(self, personsArray) subscribeNext:^(NSArray *personsArray) {
@strongify(self)
// update a set of views
[self.view setNeedsUpdateConstraints];
[self.view setNeedsLayout];
}];
[RACObserve(self, personsArray) subscribeNext:^(NSArray *personsArray) {
@strongify(self)
// update a second set of views
[self.view setNeedsUpdateConstraints];
[self.view setNeedsLayout];
}];
[RACObserve(self, personsArray) subscribeNext:^(NSArray *personsArray) {
@strongify(self)
[UIView animateWithDuration:0.4 animations:^{
[self.view layoutIfNeeded];
}];
}];
}
我更喜歡在分離不同塊的工作,因爲它提供了一個合乎邏輯的分離。我想保證最後一次訂閱消息(執行動畫塊的消息)最後發送。我怎樣才能做到這一點?
在我看來,我正在尋找的可能是鏈接(而不是多個獨立的信號集作爲訂閱,就像我在這個例子中所做的那樣),但我不能完全連接點。
謝謝!聽起來像用'-doNext:'鏈接'是我正在尋找的。 – jonsibley