doWhileSubscribed

inline suspend fun SubscriptionAware.doWhileSubscribed(stopDelay: Duration = 1.seconds, minSubscribers: Int = 1, crossinline action: suspend () -> Unit)

Runs action while this has at least minSubscribers subscribers. This function will suspend forever.

Parameters

stopDelay

the delay after which the action is cancelled if the subscriber count drops below minSubscribers.

minSubscribers

the minimum number of subscribers to keep the action running.

action

the action to invoke when the subscriber count is sufficient.

See also