objective c - How can I guarantee order of subscriber messages in ReactiveCocoa? -


i want various tasks when self.personsarray updated follows:

- (void)viewdidappear:(bool)animated {     @weakify(self)      [racobserve(self, personsarray) subscribenext:^(nsarray *personsarray) {         @strongify(self)          // update set of views          [self.view setneedsupdateconstraints];         [self.view setneedslayout];     }];      [racobserve(self, personsarray) subscribenext:^(nsarray *personsarray) {         @strongify(self)          // update 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];         }];     }]; } 

i prefer separating work in distinct blocks because provides logical separation. i'd guarantee the last subscription message (the message executes animation block) sent last. how can this?

it seems me i'm looking might chaining (rather multiple independent sets of signals subscriptions, i've done in example), can't quite connect dots.

why don't update different parts this:

- (void)viewdidappear:(bool)animated {     @weakify(self)      [racobserve(self, personsarray) subscribenext:^(nsarray *personsarray) {         @strongify(self)          // update set of views         [self updatefirstsetofview];         [self updatesecondsetofview];         [self dosomethingelse];          //         [uiview animatewithduration:0.4 animations:^{             [self.view layoutifneeded];         }];      }]; } 

you achieve same -donext: if prefer chaining.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -