我一直在玩反应性可可,我似乎无法找到一种更优雅的方式来进行条件分割而不运行该函数两次。
所以这是我的解决方案
RACSignal* registrationSignal = [self isRegistrationDone];
[[[[[registrationSignal filter:^BOOL(id value) {
if ([value boolValue] == YES) return YES;
return NO;
}] map:^id(id value) {
return [self isNewDay];
}] flattenMap:^RACStream *(id value) {
return [self willSavePreviousDay];
}] flattenMap:^RACStream *(id value) {
return [self willGenerateNotificationsForNewDay];
}]
subscribeNext:^(id x) {
NSLog(@"New Day is Checked and Saved Notifications have been completed.");
}];
[[registrationSignal filter:^BOOL(id value) {
if([value boolValue] == NO) return YES;
return NO;
}] subscribeNext:^(id x) {
[self useOnboardingController];
}];
有更好的方法来写这个吗?
干杯!