Skip to content

Instantly share code, notes, and snippets.

@krossovochkin
Created May 15, 2020 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krossovochkin/75965c198074d574b74ef12fdbbce2d6 to your computer and use it in GitHub Desktop.
Save krossovochkin/75965c198074d574b74ef12fdbbce2d6 to your computer and use it in GitHub Desktop.
map suspend kotlin
suspend fun hiThere(): Int {
return withContext(Dispatchers.Default) {
delay(1000)
40
}
}
@Test
fun test() {
CoroutineScope(Job()).launch {
flowOf(1)
.map { hiThere() }
.flowOn(Dispatchers.IO)
.collect { println(it) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment