Bind Signal from two combined request with ReactiveCocoa

261 views Asked by At

I'm new to ReactiveCocoa and I'm trying to create a Signal from two async requests.

That works fine when I try to catch next events inside my viewModel, but when I try to bind this signal in my view, it crashs.

My viewModel has these signals:

@property (nonatomic, strong) RACSignal *combineSignal;
@property (nonatomic, strong) RACSignal *info;
@property (nonatomic, strong) RACSignal *permissions;

then, when I init this class

self.info = [self getUserInfo];
self.permissions = [self getUserPermissions];
self.combineSignal = [RACSignal combineLatest:@[self.info, self.permissions]
                                     reduce:^id(NSDictionary *infoDict, NSDictionary *permissionsDict){
                                         return @(1);
                                     }];

When I try to catch next events inside this block, it works: ex:

[self.combineSignal subscribeNext:^(id _) {
    NSLog(@"OK");
}];

But, when I try to catch next events inside my view, it crashs

View

self.viewModel = [[UserViewModel alloc] initWithServices:self.viewModelServices];

[self.viewModel.combineSignal subscribeNext:^(id _) {
    NSLog(@"OK");
}];

The crash log is:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ModelServicesImpl combineSignal]: unrecognized selector sent to instance 0x7ff04243f400'
0

There are 0 answers