Skip to content

Instantly share code, notes, and snippets.

@MartinMoizard
Last active August 22, 2017 14:41
Show Gist options
  • Save MartinMoizard/42412636697c361f52e701ff3474b31d to your computer and use it in GitHub Desktop.
Save MartinMoizard/42412636697c361f52e701ff3474b31d to your computer and use it in GitHub Desktop.
final class SayHelloViewController: UIViewController {
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var validateButton: UIButton!
@IBOutlet weak var greetingLabel: UILabel!
private let viewModel = SayHelloViewModel()
private let bag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
bindViewModel()
}
private func bindViewModel() {
let inputs = SayHelloViewModel.Input(name: nameTextField.rx.text.orEmpty.asObservable(),
validate: validateButton.rx.tap.asObservable())
let outputs = viewModel.transform(input: inputs)
outputs.greeting
.drive(greetingLabel.rx.text)
.disposed(by: bag)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment