Last active
November 3, 2019 02:41
-
-
Save douglasiacovelli/edb8c7aca11ba3f3bfa6eaa34cb679f6 to your computer and use it in GitHub Desktop.
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
| fun fetchData() { | |
| viewModelScope.launch { | |
| val redditResponse = repository.getRedditPosts() | |
| when (redditResponse) { | |
| is NetworkError -> showNetworkError() | |
| is GenericError-> showGenericError(redditResponse) | |
| is Success -> showSuccess(redditResponse.value) | |
| } | |
| } | |
| } |
Author
Hi there @Divala, I've explained that on this article: “How to handle errors with Retrofit and Coroutines”: https://link.medium.com/3dBffo9Ri1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How are you implementing it in activity or fragment?