Skip to content

Instantly share code, notes, and snippets.

@GuilhE
Created April 14, 2022 10:21
Show Gist options
  • Save GuilhE/6da6c965ba7382b54f591ca25c10c23e to your computer and use it in GitHub Desktop.
Save GuilhE/6da6c965ba7382b54f591ca25c10c23e to your computer and use it in GitHub Desktop.
Medium articles - KMM with MVI+FSM
fun Flow<*>.subscribe(
onEach: (item: Any) -> Unit,
onComplete: () -> Unit,
onThrow: (error: Throwable) -> Unit
): Job =
this.onEach { onEach(it as Any) }
.catch { onThrow(it) }
.onCompletion { onComplete() }
.launchIn(CoroutineScope(Job() + Dispatchers.Main))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment