Created
May 5, 2016 16:38
-
-
Save mbalex99/ea30ec77ebf0c51d7d6a124a49d30afe to your computer and use it in GitHub Desktop.
RxSwift Login with Firebase
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
logInButton.rx_tap | |
.flatMap { [unowned self] () -> Observable<FAuthData> in | |
firebaseRef.rx_authUser(self.emailTextField.text!, password: self.passwordTextField.text!) | |
} | |
.catchError({ (error) -> Observable<String?> in | |
return Observable.just(error.someErrorMessage) // figure out what you want to say. | |
}) | |
.observeOn(MainScheduler.instance) //not needed since Firebase will always by default deliver on the MainThread. | |
.subscribeNext { [unowned self] (errorMessage: String?) in | |
if let errorMessage = errorMessage else { // SHOW ALERT } | |
else { // WE ARE GOOD, self.navigationController?.push } | |
} | |
.addDisposableTo(disposeBag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment