Search code examples
swiftreactive-cocoafrprx-swift

observing and assigning properties


In an ObjC project I am using this ReactiveCocoa pattern

RAC(self.pagingControl, currentPage) = RACObserve(self.pagingView, index);

What's the Swift equivalent with RAC4 and RxSwift? I am a bit lost in the docs on that.


Solution

  • In RAC 4 you use the MutableProperty generic type, you can then bind these to signals using the <~ operator. You can also observe these properties as signals or as signal producers using .signal and .producer respectively, access their current value with .value and change their value with .swapValue(_)