Normal. Everything works as it's written.
You have a first value at
emptyList()
and a second one with
response.items
.
In the doc, it says :
flow {
emit(1)
delay(50)
emit(2)
}.collectLatest { value ->
println("Collecting $value")
delay(100) // Emulate work
println("$value collected")
}
In the collect, the delay time is longer than in the flow. So if you send 20 values in your flow every 50ms, but your collect can treat only one value data in 100ms, you'll only work with the final value.
But if you send 20 values in your flow every 500ms, and your collect can still treat one value every 100ms,
you'll work with the 20 values.
EDIT : With the first value wich finish the process and end the coroutine. If your coroutine is not killed, you'll work with the 20 values. In my link below, at the end of the first value, the GlobalScope is not kept alive.