Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


observe every item in a racsequence update observations when sequence has new i using -'reactive-cocoa,racsequence'


observe every item in a racsequence update observations when sequence has new i  using -'reactive-cocoa,racsequence'

This is a similar question to an earlier question that asked about observing every item in a RACSequence ‚ÄĒ the correct answer was something like:

RACSignal *valid = [[RACSignal combineLatest:
                     [self.viewModels map:^id(ViewModel *viewModel) {
                       return [RACObserve(viewModel, state) startWith:@(viewModel.state)];
                     }]
                    ]
                    map:^(RACTuple *states) {
                      return @([states.rac_sequence all:^BOOL(NSNumber *state) {
                        return state.unsignedIntegerValue == Completed;
                      }]);
                    }
                   ];


My variation on this is that I'd like to also handle the case where ViewModel instances are added/removed from the sequence as well. I can do this by invalidating a RACDisposable stored in an instance variable or property, but it would be great to do this without adding any extra state. What's the right way to do this?
    

asked Sep 7, 2015 by rajesh
0 votes
11 views



Related Hot Questions



Government Jobs Opening


...