kotlin-flow-extensions / hu.akarnokd.kotlin.flow / kotlinx.coroutines.flow.Flow / replay

replay

@FlowPreview fun <T, R> Flow<T>.replay(transform: suspend (Flow<T>) -> Flow<R>): Flow<R>

Shares a single collector towards the upstream source and multicasts cached values to any number of consumers which then can produce the output flow of values.

@FlowPreview fun <T, R> Flow<T>.replay(maxSize: Int, transform: suspend (Flow<T>) -> Flow<R>): Flow<R>

Shares a single collector towards the upstream source and multicasts up to a given maxSize number of cached values to any number of consumers which then can produce the output flow of values.

@FlowPreview fun <T, R> Flow<T>.replay(maxTime: Long, unit: TimeUnit, transform: suspend (Flow<T>) -> Flow<R>): Flow<R>

Shares a single collector towards the upstream source and multicasts up to maxTime old cached values to any number of consumers which then can produce the output flow of values.

@FlowPreview fun <T, R> Flow<T>.replay(maxSize: Int, maxTime: Long, unit: TimeUnit, transform: suspend (Flow<T>) -> Flow<R>): Flow<R>
@FlowPreview fun <T, R> Flow<T>.replay(maxSize: Int, maxTime: Long, unit: TimeUnit, timeSource: (TimeUnit) -> Long, transform: suspend (Flow<T>) -> Flow<R>): Flow<R>

Shares a single collector towards the upstream source and multicasts up to a given maxSize number and up to maxTime old cached values to any number of consumers which then can produce the output flow of values.