Created
April 21, 2020 10:30
-
-
Save PatilShreyas/7b299785b63c53c7ee939f2fc4fcc255 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
private suspend fun loadPosts() { | |
viewModel.getAllPosts().collect { state -> | |
when (state) { | |
is State.Loading -> { | |
showToast("Loading") | |
} | |
is State.Success -> { | |
val postText = state.data.joinToString("\n") { | |
"${it.postContent} ~ ${it.postAuthor}" | |
} | |
binding.textPostContent.text = postText | |
} | |
is State.Failed -> showToast("Failed! ${state.message}") | |
} // END when | |
} // END collect | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment