Skip to content

Instantly share code, notes, and snippets.

@skydoves
Created April 11, 2022 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skydoves/e37561505e855418a126d8684aab59db to your computer and use it in GitHub Desktop.
Save skydoves/e37561505e855418a126d8684aab59db to your computer and use it in GitHub Desktop.
handle_api_viewmodel_layer
viewModelScope.launch {
when (val response = posterRemoteDataSource.invoke()) {
is NetworkResult.Success -> posterFlow.emit(response.data)
is NetworkResult.Error -> errorFlow.emit("${response.code} ${response.message}")
is NetworkResult.Exception -> errorFlow.emit("${response.e.message}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment