ReactiveCocoa subscribeNext with nil check

In most cases, when I sign below, Ill checks to see if the value is nil first, for example:

[[RACObserve(self.viewModel, stockViewModel.stock.imageURL) takeUntil:[self takeUntil]] subscribeNext:^(id
    value) {
        @strongify(self);

//Check if not nil
if (value) {
//Do somthing
}

    }];

Attached to do this every time, I try to change the category for RACSignal, which will transform this check for me, but I'm not sure how I can get the value (and not the value of the block, the next value) from this

- (RACDisposable *)subscribeNext:(void (^)(id x))nextBlock {
    NSCParameterAssert(nextBlock != NULL);

    RACSubscriber *o = [RACSubscriber subscriberWithNext:nextBlock error:NULL completed:NULL];
    return [self subscribe:o];
}

Any help? Thank!

+4
source share
1 answer

An operation ignorein RACSignal can be used to filter specific values:

[[RACObserve(self, maybeNilProperty) ignore:nil] subscribeNext:^(id x) {
  // x can't be nil
}];
+14
source

All Articles