Skip to content

Instantly share code, notes, and snippets.

@GuilhE
Created Apr 14, 2022
Embed
What would you like to do?
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