Created
September 8, 2021 06:01
-
-
Save mattmook/d313bf3b26444ea8832b1207c2661dd1 to your computer and use it in GitHub Desktop.
OrbitMultiplatform-subscribe.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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