Skip to content

Instantly share code, notes, and snippets.

@johnlahboo
Created September 27, 2016 12:05
Show Gist options
  • Save johnlahboo/9e0cf34ff771746d29fd34db0c6c1c9d to your computer and use it in GitHub Desktop.
Save johnlahboo/9e0cf34ff771746d29fd34db0c6c1c9d to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var resultLabel: UILabel!
var viewModel: ViewModel!
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func checkEvenNumber(sender: AnyObject) {
viewModel = ViewModel()
textField
.rx_observe(String.self, "text")
.bindTo(viewModel.numberVariable)
.addDisposableTo(disposeBag)
viewModel.isEvenObservable
.subscribeNext {isEven in
self.resultLabel.text = isEven
}
.addDisposableTo(disposeBag)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment