This question is the same like this and this, but about Kotlin flow.
What needs to be achieved:
There is simple solution with dynamic debounce timeout:
var firstEmission = true
flow.debounce {
if (firstEmission) {
firstEmission = false
0L
} else DEBOUNCE_TIMEOUT
}
Also possible to do this way:
merge(
flow.take(1),
flow.drop(1).debounce(DEBOUNCE_TIMEOUT)
)