Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid subscribeNext be called at subscription time

I am doing the following code:

[RACObserve(obj, property) subscribeNext:^(id x) {
    NSLog(@"property was changed");
}];
obj.property = @"bla";

This code call the block twice, one at subscription time and one when the property is modified. I want the block be called only when the property is modified. Is there any way this behavior can be avoided with reactivecocoa?

like image 943
felipebv Avatar asked Dec 10 '25 05:12

felipebv


1 Answers

Use the -skip: operator to prevent the subscriber from getting called with the property's initial value.

like image 81
Dave Lee Avatar answered Dec 11 '25 18:12

Dave Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!