Skip to content

Instantly share code, notes, and snippets.

@Shivamdhuria
Last active December 12, 2020 20:57
Show Gist options
  • Save Shivamdhuria/754a1c0879e3addc52c36db23e4dd0b9 to your computer and use it in GitHub Desktop.
Save Shivamdhuria/754a1c0879e3addc52c36db23e4dd0b9 to your computer and use it in GitHub Desktop.
lifecycleScope.launch {
viewModel.dogImagesFlow.collect {
when (it) {
is ResultWrapper.NetworkError -> {
errorText.append("${it.errorMessage} \n")
...
}
is ResultWrapper.Success<*> -> {
...
showLoading(false)
adapter.submitList(it.value as? List<String>)
}
is ResultWrapper.Loading -> {
...
showLoading(it.isLoading)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment