使用ReactiveCocoa从两个组合请求中绑定信号

时间:2015-06-15 22:08:09

标签: objective-c reactive-cocoa

我是ReactiveCocoa的新手,我正在尝试从两个异步请求中创建一个Signal。

当我尝试捕获viewModel中的下一个事件时,它工作正常,但是当我尝试在我的视图中绑定此信号时,它会崩溃。

我的viewModel有这些信号:

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

然后,当我开始这个课程时

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

当我尝试捕获此块中的下一个事件时,它可以工作:ex:

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

但是,当我尝试捕捉视图中的下一个事件时,它会崩溃

查看

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

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

崩溃日志是:

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

0 个答案:

没有答案