delayAtLeast

fun <T> Flow<T>.delayAtLeast(duration: Duration, condition: (T) -> Boolean = { true }): Flow<T>

Ensures each emitted item is held for at least duration from the moment this flow is collected.

A timer starts at collection time. Items for which condition returns true are suspended until the timer has elapsed; if the timer already fired before the item arrived, they pass through immediately. Items for which condition returns false are always emitted immediately, regardless of the timer.

Typical use: mix fast-path items (e.g. progress/pending signals) that must appear instantly with a result item that should be held long enough for a minimum-display animation to complete.

Parameters

duration

minimum time to wait before emitting items that satisfy condition.

condition

predicate that controls which items are subject to the minimum delay. Defaults to { true } — all items are delayed.