Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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