If I'm using RACable like this:
[RACAbleWithStart(self.myProp) subscribeNext:^(id x) {
// Do stuff
}];
How can can I access the old value of myProp (before the change the caused the signal to fire)? So I can access it like this:
[RACAbleWithStart(self.myProp) subscribeNext:^(id x) {
// Do stuff
id newValue = x;
id oldValue = RAC_oldValue;
}];
I have used this snippet with success:
[[object rac_valuesAndChangesForKeyPath:@"property" options:NSKeyValueObservingOptionOld observer:self] subscribeNext:^(RACTuple *tuple) {
id newObject = tuple.first;
NSDictionary *change = tuple.second;
id oldObject = change[NSKeyValueChangeOldKey];
}];
Source: ReactiveCocoa documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With