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