This release refocuses ReactiveCocoa on reactive bindings for Apple’s Cocoa and Cocoa Touch frameworks.
The core Swift APIs have been extracted to ReactiveSwift, and ReactiveCocoa now depends on it. The old Objective-C APIs from RAC 2.x have been moved to ReactiveObjC and bridging code is available in ReactiveObjCBridge. You can read more about this in the CHANGELOG.
The new reactive bindings build on the excellent work done by @neilpa on Rex. AppKit and UIKit objects are extended via a reactive
property that houses Signal
s and BindingTarget
s to be used with ReactiveSwift’s <~
operator.
class VM {
let name: Property<String>
let submit: Action<(), (), NoError>
}
class VC: UIViewController {
let viewModel: VM
let nameLabel: UILabel
let submitButton: UIButton
override func viewDidLoad() {
// Update nameLabel's text whenever the VM's name changes
nameLabel.reactive.text <~ vm.name
// Execute the submit action whenever the button is tapped
submitButton.reactive.pressed = CocoaAction(vm.submit)
}
}
A more detailed explanation is available in the README.
To learn more about the changes to core APIs, please refer to ReactiveSwift 1.0. Extensive use of Swift’s @available declaration has been used to ease migration from ReactiveCocoa 4. Xcode should have fix-its for almost all changes from older APIs.
Thank you to all of @ReactiveCocoa/reactivecocoa and all our contributors, but especially to @andersio, @liscio, @mdiep, @NachoSoto, @neilpa, and @sharplet. ReactiveCocoa is only possible due to the many hours of work that these individuals have volunteered. ❤️