Skip to content

Instantly share code, notes, and snippets.

@GianpaMX
Created August 26, 2020 23:36
Show Gist options
  • Save GianpaMX/c7bb7a9155fe7720d45c5a16803e8e4e to your computer and use it in GitHub Desktop.
Save GianpaMX/c7bb7a9155fe7720d45c5a16803e8e4e to your computer and use it in GitHub Desktop.
val errors = errorChannel.asFlow().handleErrors()
private fun Flow<Throwable>.handleErrors(): Flow<Throwable> = flow {
distinctUntilChanged().collect {
if (it is ZenModeApi.AccessDeniedException) {
navigationChannel.send(ClockNavDirection.AskDndPermission)
} else {
emit(it)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment