反应性可可有条件分裂?

时间:2015-06-08 06:12:12

标签: ios cocoa reactive-cocoa

我一直在玩反应性可可,我似乎无法找到一种更优雅的方式来进行条件分割而不运行该函数两次。

所以这是我的解决方案

 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];

    }];

有更好的方法来写这个吗?

干杯!

0 个答案:

没有答案