I am woking on a new new swift 2 project using ReactiveCocoa4 and I am wondering how to observe a property change like I dit it before in ObjC.
[RACObserve(self,self.model.wifiState) subscribeNext:^(id newValue){ @strongify(self); self.wifiState = newValue; }];
Do you have any hint?
Thanks
Thierry
You can do the same using DynamicProperty
:
DynamicProperty(object: self.model, keyPath: "wifiState")
.signal // or `producer` if you care about the current value
.map { $0 as! WifiState } // Necessary because there is no way to infer the type of the given keyPath.
.observeNext { [unowned self] self.wifiState = $0 }