WhileSubscribed

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

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

It has the following optional parameters:

This function throws IllegalArgumentException when either stopTimeoutMillis or replayExpirationMillis are negative.