Created
September 27, 2016 12:05
-
-
Save johnlahboo/9e0cf34ff771746d29fd34db0c6c1c9d 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
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