Created
May 15, 2020 13:50
-
-
Save krossovochkin/75965c198074d574b74ef12fdbbce2d6 to your computer and use it in GitHub Desktop.
map suspend kotlin
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
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