From 37e6c09194f8de604ff4fbb9dbd4e0b2d4d2e9cd Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Tue, 19 May 2015 21:20:10 +0200 Subject: [PATCH] Brushes up examples. --- .../Views/GitHubSignupViewController.swift | 27 ++++++++++--------- .../IntroductionExampleViewController.swift | 4 ++- RxExample/RxExample/OSX/Main.storyboard | 22 +++++++-------- RxExample/RxExample/iOS/Main.storyboard | 6 ++--- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift b/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift index 55e9d80e..7f25fd9e 100644 --- a/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift +++ b/RxExample/RxExample/Examples/GitHubSignup/Views/GitHubSignupViewController.swift @@ -130,20 +130,23 @@ class GitHubSignupViewController : ViewController { let repeatPassword = repeatedPasswordOutlet.rx_text() let signupSampler = self.signupOutlet.rx_tap() - let usernameValidation = username >- map { username in - return validationService.validateUsername(username) - } >- switchLatest >- variable + let usernameValidation = username + >- map { username in + return validationService.validateUsername(username) + } + >- switchLatest + >- variable - let passwordValidation = password >- map { password in - return validationService.validatePassword(password) - } >- variable + let passwordValidation = password + >- map { password in + return validationService.validatePassword(password) + } + >- variable - let repeatPasswordValidation = combineLatest( - password, - repeatPassword - ) { (password, repeatedPassword) in - return validationService.validateRepeatedPassword(password, repeatedPassword: repeatedPassword) - } >- variable + let repeatPasswordValidation = combineLatest(password, repeatPassword) { (password, repeatedPassword) in + validationService.validateRepeatedPassword(password, repeatedPassword: repeatedPassword) + } + >- variable let signingProcess = combineLatest(username, password) { ($0, $1) } >- sampleLatest(signupSampler) diff --git a/RxExample/RxExample/Examples/Introduction/IntroductionExampleViewController.swift b/RxExample/RxExample/Examples/Introduction/IntroductionExampleViewController.swift index b1d205a8..64deaa3d 100644 --- a/RxExample/RxExample/Examples/Introduction/IntroductionExampleViewController.swift +++ b/RxExample/RxExample/Examples/Introduction/IntroductionExampleViewController.swift @@ -29,6 +29,7 @@ class IntroductionExampleViewController : ViewController { return (a.toInt() ?? 0, b.toInt() ?? 0) } + // bind result to UI sum >- map { (a, b) in return "\(a + b)" @@ -36,8 +37,9 @@ class IntroductionExampleViewController : ViewController { >- c.rx_subscribeTextTo >- disposeBag.addDisposable - // also, read the result out loud + // Also, tell it out loud let speech = NSSpeechSynthesizer() + sum >- map { (a, b) in return "\(a) + \(b) = \(a + b)" diff --git a/RxExample/RxExample/OSX/Main.storyboard b/RxExample/RxExample/OSX/Main.storyboard index 8ad84095..292a7b69 100644 --- a/RxExample/RxExample/OSX/Main.storyboard +++ b/RxExample/RxExample/OSX/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -59,7 +59,7 @@ - + @@ -81,7 +81,7 @@ - + @@ -100,7 +100,7 @@