Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Foundation
import RxSwift
import RxSwiftExt
import RxCocoa
extension Variable {
func bidirectionalBind(with controlProperty: ControlProperty<Element>) -> Disposable {
let bindingToControl = self
.asDriver()
.drive(controlProperty)
let bindingToVariable = controlProperty
.skipUntil(self.asObservable())
.bindTo(self)
return Disposables.create(bindingToControl, bindingToVariable)
}
func bidirectionalBind(with controlProperty: ControlProperty<Optional<Element>>) -> Disposable {
let bindingToControl = self
.asDriver()
.drive(controlProperty)
let bindingToVariable = controlProperty
.skipUntil(self.asObservable())
.unwrap()
.bindTo(self)
return Disposables.create(bindingToControl, bindingToVariable)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.