Reactive two-way binding
Switch branches/tags
Clone or download
a.makushkin
Latest commit be15bae Oct 10, 2018

README.md

RxBiBinding

Build Status Carthage compatible Version License Platform

Example

Binding between two ControlProperty

let disposeBag = DisposeBag()

var textFieldFirst = UITextField()
var textFieldSecond = UITextField()

(textFieldFirst.rx.text <-> textFieldSecond.rx.text).disposed(by: disposeBag)

Binding between two BehaviorRelay

let disposeBag = DisposeBag()

var textFirst = BehaviorRelay<String?>(value: "")
var textSecond = BehaviorRelay<String?>(value: "")

(textFirst <-> textSecond).disposed(by: disposeBag)

Binding between ControlProperty and BehaviorRelay

let disposeBag = DisposeBag()

var text = BehaviorRelay<String?>(value: "")
var textField = UITextField()

(textField.rx.text <-> text).disposed(by: disposeBag)

Binding between two NSObject

class TestClass: NSObject {
    @objc dynamic var string = "TestString"
}

let disposeBag = DisposeBag()
var test1 = TestClass()
var test2 = TestClass()

((test1, "string") <-> (test2, "string")).disposed(by: disposeBag)

Requirements

iOS >= 10

Installation

RxBiBinding is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RxBiBinding'

Carthage

carthage update --platform ios

Thanks

This solution is based on ReactiveCocoa (Obj-C version)

License

RxBiBinding is available under the MIT license. See the LICENSE file for more info. Copyright (c) RxSwiftCommunity