Last active
April 6, 2017 12:15
-
-
Save laiso/7a551d0fc905a0dbf1f0ca16c0824230 to your computer and use it in GitHub Desktop.
Error Handling in 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
// MARK: Submit Button - action | |
viewModel.loggedIn.asObservable() | |
.observeOn(MainScheduler.instance) | |
.retryWhen { errorObservable -> Observable<Error> in | |
errorObservable.map { [weak self] error in | |
let alert = ErrorAlertBuilder(error: error).build() | |
self?.present(alert, animated: true, completion: nil) | |
return error | |
} | |
} | |
.subscribe(onNext: { [weak self] in | |
guard let strongSelf = self else { return } | |
self?.dismiss(animated: true, completion: { | |
self?.delegate?.didSignin(strongSelf) | |
}) | |
}) | |
.addDisposableTo(disposeBag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment