Created
June 28, 2018 14:03
-
-
Save davidbilik/4357f40bc57541fb6972cfb31d420270 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
fun onViewCreated() { | |
disposables += viewModel.observeLoginResult() | |
.observeOnMainThread() | |
.subscribe { | |
when (it) { | |
is LoginResult.LoginOk -> finishLogin() | |
is LoginResult.LoginError -> { | |
when (it.error) { | |
is NoInternetConnectionException -> showNoConnectionError() | |
is InvalidCredentialsException -> showInvalidCredentialsError() | |
is GeneralServerException -> showGeneralServerError() | |
is ValidationException -> showValidationErrors(it.error.errors) | |
is UnexpectedException -> unexpectedError() // crash? | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment