I have an NSArray of ViewModel objects on my ViewController:
@property (nonatomic, strong) NSArray *viewModels;
A ViewModel object looks something like this:
@interface ViewModel : NSObject
@property (nonatomic) BOOL isSelected;
@end
I am trying to create a RACSignal for the enabledSignal on a RACCommand's init method:
- (id)initWithEnabled:(RACSignal *)enabledSignal signalBlock:(RACSignal * (^)(id input))signalBlock
This signal will tell the Command to be enabled if there are either 0 viewModel objects selected or if the number of viewModels selected is equal to the total count of the viewModels.
I can create a RACSequence which will give me the viewModel objects that are selected by this code:
RACSequence *selectedViewModels = [[self.viewModels.rac_sequence
filter:^BOOL(ViewModel *viewModel) {
return viewModel.isSelected == YES;
}]
map:^id(ViewModel *viewModel) {
return viewModel;
}];
How would I go about creating the valid signal?