0
所以,当我试图获取一些数据时,RACCommand返回这个错误。该命令被禁用,无法执行
我有例如一个选择器,当用户滚动它,应用程序从服务器获取数据,并告诉他们,但如果用户滚动快,(在建之前的操作)RACCommand得到这个错误:
Error Domain=RACCommandErrorDomain Code=1 "The command is disabled and cannot be executed" UserInfo={RACUnderlyingCommandErrorKey=<RACCommand: 0x174280050>, NSLocalizedDescription=The command is disabled and cannot be executed}
我知道,它与一些取消机制有关,但我尝试了很多例子,而且效果不佳。
它我的一段代码:
@weakify(self);
[[[self.viewModel makeCommand] execute:nil]
subscribeError:^(NSError *error) {
@strongify(self);
[self showAlertWithError:error];
}];
和视图模型:
- (RACCommand*)makeCommand {
if (!_makeCommand) {
_makeCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
return [self getVehicleMake];
}];
}
return _makeCommand;
}
- (RACSignal*)getVehicleMake {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
[[self.forumService getForumMakesWithYear:@([self.selectedYear integerValue])
category:self.vehicleCategory]
subscribeNext:^(RACTuple *result) {
self.makes = result.first;
[subscriber sendNext:self.makes];
} error:^(NSError *error) {
[subscriber sendError:error];
} completed:^{
[subscriber sendCompleted];
}];
return [RACDisposable disposableWithBlock:^{
}];
}];
}
所以,你的意思是RACCommand没有取消机制? –
RACCommand没有取消机制 – mdiep