Skip to content

//reactivestate-core/com.ensody.reactivestate/conflatedWorker

conflatedWorker

[common]\ fun <T, R> Flow<T>.conflatedWorker(timeoutMillis: Long = 0, transform: FlowTransform<T, R>): Flow<R>

Executes each lambda in a Flow using conflatedMap.

Computes first and last element and intermediate when possible. The first computation starts immediately and we throw away all intermediate changes until the computation is finished and then recompute again for the last change that happened in the meantime.

This is useful e.g. when you have a constant stream of events (e.g. WebSocket change notifications, keyboard input, mouse moved, etc.) and you want to show intermediate results.

If you only want to show the latest result you can use latestWorker.

Parameters

common

timeoutMillis Additional delay before the last element is computed (throwing away intermediate elements).