SharingStarted

interface SharingStarted (source)

Functions

command

abstract fun command(
    subscriptionCount: StateFlow<Int>
): Flow<SharingCommand>

Transforms the subscriptionCount state of the shared flow into the flow of commands that control the sharing coroutine. See the SharingStarted interface documentation for details.

Companion Object Properties

Eagerly

val Eagerly: SharingStarted

Sharing is started immediately and never stops.

Lazily

val Lazily: SharingStarted

Sharing is started when the first subscriber appears and never stops.

Companion Object Functions

WhileSubscribed

fun WhileSubscribed(
    stopTimeoutMillis: Long = 0,
    replayExpirationMillis: Long = Long.MAX_VALUE
): SharingStarted

Sharing is started when the first subscriber appears, immediately stops when the last subscriber disappears (by default), keeping the replay cache forever (by default).

Companion Object Extension Functions

WhileSubscribed

fun SharingStarted.Companion.WhileSubscribed(
    stopTimeout: <ERROR CLASS> = Duration.ZERO,
    replayExpiration: <ERROR CLASS> = Duration.INFINITE
): SharingStarted

Sharing is started when the first subscriber appears, immediately stops when the last subscriber disappears (by default), keeping the replay cache forever (by default).