Skip to content

Instantly share code, notes, and snippets.

@IsaAliev
Created November 2, 2019 09:58
Show Gist options
  • Save IsaAliev/92b0c690560d9c1ff4276b52f108c587 to your computer and use it in GitHub Desktop.
Save IsaAliev/92b0c690560d9c1ff4276b52f108c587 to your computer and use it in GitHub Desktop.
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