completingSharedFlowCache

fun <K : Any, T> completingSharedFlowCache(scope: CoroutineScope, started: SharingStarted = SharingStarted.WhileSubscribed(), replay: Int = 0): CompletingSharedFlowCache<K, T>(source)

Creates a CompletingSharedFlowCache backed by a SharedFlowCache: each supplier's terminal completion/error is materialised into the shared stream and rematerialised per subscriber, so - unlike a plain SharedFlow - completion and errors propagate downstream. The entry is evicted as the terminal is published, so a downstream retry re-resolves to a fresh entry (re-running the supplier) rather than re-reading the terminal.

Each subscription re-resolves the entry, and the entry is evicted before its terminal is published, so a subscriber arriving after completion rebuilds (re-running the supplier) rather than attaching to the terminated stream - the terminal is never replayed to a late subscriber, so replay does not need to cover it.

Parameters

scope

parent scope; each key's sharing coroutine is a child of it.

started

the SharingStarted strategy applied to each key's upstream.

replay

number of values replayed to new subscribers of a live (not-yet-completed) entry.