Skip to content

Instantly share code, notes, and snippets.

@varshabhatia007
Last active May 19, 2019 12:36
Show Gist options
  • Save varshabhatia007/67262a575ccb645cd8a1ecf7219d35e9 to your computer and use it in GitHub Desktop.
Save varshabhatia007/67262a575ccb645cd8a1ecf7219d35e9 to your computer and use it in GitHub Desktop.
private fun getCustomerDataFromApi() {
customerUsecase.getCustomerData()
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { view.showLoader() }
.doOnEvent { _, _ -> view.hideLoader() }
.subscribe(
{
view.populateData(it)
},
{ e ->
Log.e(TAG(), e.message, e)
if (e is NetworkError) {
view.showError(e.toModel())
} else {
view.showCustomError()
}
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment