Skip to content

Instantly share code, notes, and snippets.

@NoNews

NoNews/Chain.kt Secret

Last active January 12, 2022 11:09
Show Gist options
  • Save NoNews/1cb6c5fbf129e6efb486e9825edec408 to your computer and use it in GitHub Desktop.
Save NoNews/1cb6c5fbf129e6efb486e9825edec408 to your computer and use it in GitHub Desktop.
CoroutineScope(context = Dispatchers.Main.immediate).launch() {
doAction()
flowOf("Hey")
.onEach { doAction() }
.map { it.length }
.onStart { doAction() }
.flowOn(Dispatchers.Default)
.flatMapMerge {
doAction()
flowOf(1)
.flowOn(Dispatchers.Main)
.onEach { doAction() }
}
.flowOn(Dispatchers.IO)
.collect {
doAction()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment