i'm new reactive cocoa. i'm trying achieve notified every time property value changes. however, don't want notified when property set same value. here's code:
self.testproperty = 0; [[racobserve(self, self.testproperty) skip:1] subscribenext:^(id x) { nslog(@"did change: %@", x); }]; self.testproperty = 1; self.testproperty = 1; self.testproperty = 1; self.testproperty = 1; self.testproperty = 1;
and on console's output
> did change: 1 > did change: 1 > did change: 1 > did change: 1 > did change: 1
i expected "did change" printed once, not five. there way subscribe new values?
there method that, distinctuntilchanged:
[[[racobserve(self, self.testproperty) skip:1] distinctuntilchanged] subscribenext:^(id x) { nslog(@"did change: %@", x); }];
Comments
Post a Comment