例如,我目前的实现如下:
- (RACSignal *)getPlaylist {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
[[[buttonClickSignal
flattenMap:^(UIButton *sender) {
return [self logInWithUsername:username password:password];
}]
flattenMap:^(NSDictionary *json) {
return [self fetchPlaylistForToken:token];
}]
subscribeNext:^(NSDictionary *json) {
[subscriber sendNext:json];
[subscriber sendCompleted];
}];
return nil;
}];
}
如何在不使用[RACSignal createSignal]方法的情况下返回新信号?
答案 0 :(得分:3)
为什么不回复映射的buttonClickSignal
?
我没有看到任何问题:
- (RACSignal *)getPlaylist {
return [[buttonClickSignal
flattenMap:^(UIButton *sender) {
return [self logInWithUsername:username password:password];
}]
flattenMap:^(NSDictionary *json) {
return [self fetchPlaylistForToken:token];
}];
}
由于您现在似乎忽略了错误,如果任何flattenMapped信号错误,您当前的实现将永远不会完成。