Created
November 2, 2019 09:58
-
-
Save IsaAliev/92b0c690560d9c1ff4276b52f108c587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Bond | |
class ViewController: UIViewController { | |
@IBOutlet weak var greetingLabel: UILabel! | |
@IBOutlet weak var nameTextField: UITextField! | |
@IBOutlet weak var sayHelloButton: UIButton! | |
let model = ViewModel() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
bindWithModel() | |
} | |
private func bindWithModel() { | |
model.greeting.bind(to: greetingLabel.reactive.text).dispose(in: bag) | |
model.name.bidirectionalBind(to: nameTextField.reactive.text).dispose(in: bag) | |
sayHelloButton.reactive.tap.observeNext { [unowned self] _ in | |
self.model.sayHello() | |
}.dispose(in: bag) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment