import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.runBlocking
val numbers: StateFlow<Int> = (1..100).asFlow()
.onEach { delay(100) }
.let {
runBlocking {
it.stateIn(this)
}
}
fun main(){
println("hello")
println(numbers.value)
println("bye")
}
I expect that main function finish only in 100ms (wait for first emission)
but second print happens when all items emitted (takes about 100*100 ms) and also prints last item instead of first one!
am I missing something or it is a bug ?