My understanding is that conflate() emits only the latest value when applied to a flow. How is the "latest value" determined since the underlying flow is a hot observable?
At any point, it can't know if more emissions are coming but it doesn't just withhold from emitting. I understand that there's a buffer involved but still unclear as to how it can determine what is the "latest value"
I tried reading the Kotlin documentation which gives this example:
val flow = flow {
for (i in 1..30) {
delay(100)
emit(i)
}
}
val result = flow.conflate().onEach { delay(1000) }.toList()
assertEquals(listOf(1, 10, 20, 30), result)
This seems to suggest that when the collection happens, conflate() simply takes the latest emission out of all (buffered) emitted events which makes sense. However, typically the collection is never delayed and it says that collection is triggered whenever an emission happens - this seems contradictory?