dariuszbacinski
11/07/2019, 8:36 AM@Test
fun coroutineTest() {
runBlocking {
flowOf("any").map {
val result = ioFunction() //crash java.lang.ClassCastException: kotlin.coroutines.intrinsics.CoroutineSingletons cannot be cast to java.util.Map
result
}.collect { result ->
Log.v("$result")
}
}
}
suspend fun ioFunction(): Map<Long, Int> = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
mapOf(1L to 4)
}
how can is use suspend function in when mapping Flow? above code crashes, but it works when I remove suspend function and use normal blocking functionoctylFractal
11/07/2019, 8:38 AMdelay
and not sleepCOROUTINE_SUSPENDED
internal value being leakeddariuszbacinski
11/07/2019, 8:39 AMoctylFractal
11/07/2019, 8:45 AMdariuszbacinski
11/07/2019, 8:55 AM