OC + RAC (八) 查看信号状态和跳过信号

-(void)_test9{
    /// RACCommand又叫命令 是用来收发数据的 监听按钮点击,网络请求。。。。
    
        RACCommand * command = [[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
    
            NSLog(@"input = %@",input);
            return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
    
                [subscriber sendNext:@"666666"];
                [subscriber sendCompleted];
                return nil;
            }];
    
        }];
    /// 查看信号是在执行还是结束了
        [command.executing subscribeNext:^(NSNumber * _Nullable x) {
    
            //        NSLog(@"查看信号是在执行还是结束了 %d",[x boolValue]);
    
            if ([x boolValue]) {
    
                NSLog(@"还在执行");
            }
            else
            {
                NSLog(@"执行结束了");
            }
        }];
    
    
    ///忽略几次
//        [[command.executing skip:1] subscribeNext:^(NSNumber * _Nullable x) {
//
//            if ([x boolValue]) {
//                NSLog(@"还在执行");
//            }
//            else
//            {
//                NSLog(@"执行结束了");
//            }
//        }];
    
        [command execute:@"99999"];
}

猜你喜欢

转载自www.cnblogs.com/liuw-flexi/p/10805850.html