Created
October 5, 2021 19:59
-
-
Save brunogabriel/4a0a21451407c55bc609d4f3b349a801 to your computer and use it in GitHub Desktop.
Método getPosts
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 takePosts() { | |
compositeDisposable + useCase.takePosts() | |
.subscribeOn(appSchedulers.io) | |
.observeOn(appSchedulers.main) | |
.doOnSubscribe { _displayingView.value = DisplayingView.Loading.ordinal } | |
.subscribeBy(onError = { | |
_displayingView.value = DisplayingView.Error.ordinal | |
_errorMessage.value = it.message ?: DEFAULT_ERROR_MESSAGE | |
}, onSuccess = { result -> | |
if (result.isNotEmpty()) { | |
_postsResult.value = result | |
_displayingView.value = DisplayingView.Success.ordinal | |
} else { | |
_displayingView.value = DisplayingView.Empty.ordinal | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment