Created
January 12, 2016 14:57
-
-
Save macbellingrath/4e955b260b3cf1de5cf9 to your computer and use it in GitHub Desktop.
Comparing ReactiveCocoa with RxSwift
This file contains hidden or 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
/* RAC*/ | |
let userNameStrings = userNameTextfield | |
.rac_textSignal() | |
.toSignalProducer() | |
.map { text in text as! String } | |
let passwordStrings = passwordTextfield.rac_textSignal() | |
.toSignalProducer() | |
.map { password in password as! String } | |
let signal = zip(userNameStrings, passwordStrings) | |
signal.startWithNext { (un, pw) in self.submitButton.enabled = (un.characters.count > 0) && (pw.characters.count > 0) } | |
//Or ? | |
userNameTextfield.rac_textSignal() | |
.subscribeNext { _ in self.userNameTextfield.backgroundColor = self.userNameTextfield.validate() } | |
passwordTextfield.rac_textSignal() | |
.subscribeNext { _ in self.passwordTextfield.backgroundColor = self.passwordTextfield.validate() } | |
/*RxSwift */ | |
nameTextField.rx_text | |
.map{ "Hello " + $0 } | |
.throttle(0.5, scheduler: MainScheduler.instance) | |
.subscribeNext { self.greetingLabel.text = $0 } | |
.addDisposableTo(disposebag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment