Skip to content

Instantly share code, notes, and snippets.

@aleweichandt
Created August 16, 2021 19:01
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 aleweichandt/34ad5f398cbcdc299be3a7fb6db58c6f to your computer and use it in GitHub Desktop.
Save aleweichandt/34ad5f398cbcdc299be3a7fb6db58c6f to your computer and use it in GitHub Desktop.
error handling
viewModelScope.launch {
getAllTodosUseCase(force)
.onStart { _refreshing.value = true }
.onCompletion { _refreshing.value = false }
.collect { response ->
when (response) {
is Result.Success -> _todos.value = response.result
is Result.Failure -> _error.value = response.error
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment