Last active
August 22, 2017 14:41
-
-
Save MartinMoizard/42412636697c361f52e701ff3474b31d 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
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