Skip to content

Instantly share code, notes, and snippets.

@davidbilik
Created June 28, 2018 14:03
Show Gist options
  • Save davidbilik/4357f40bc57541fb6972cfb31d420270 to your computer and use it in GitHub Desktop.
Save davidbilik/4357f40bc57541fb6972cfb31d420270 to your computer and use it in GitHub Desktop.
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