Created
February 16, 2021 15:02
-
-
Save DarkAbhi/6b560c0ffec24340dbec372eae88b5fb 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
CoroutineScope(Dispatchers.Main).launch { | |
loadPost() | |
} | |
private suspend fun loadPost() { | |
viewModel.getPost().collect { | |
when (it) { | |
is State.Loading -> { | |
Timber.i("LOADING") | |
} | |
is State.Success -> { | |
Timber.i("${it.data}") | |
Timber.i("SUCCESS") | |
} | |
is State.Failed -> { | |
Timber.i(it.message) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment