collectWithLifecycle

fun <T> TickingValueProvider<T>.collectWithLifecycle(lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, minActiveState: Lifecycle.State = Lifecycle.State.STARTED, clock: ClockWrapper = SYSTEM_CLOCK.collectAsStateWithLifecycle(lifecycleOwner, minActiveState).value, timeZone: TimeZone = SYSTEM_TIMEZONE.collectAsStateWithLifecycle(lifecycleOwner, minActiveState).value, maxTick: Duration? = null): T(source)

Collects and returns values from TickingValueProvider in a lifecycle-aware manner.

Parameters

lifecycleOwner

LifecycleOwner whose lifecycle is used to restart collecting values from this TickingValueProvider

minActiveState

Lifecycle.State in which the upstream TickingValueProvider gets collected. The collection will stop if the lifecycle falls below that state, and will restart if it's in that state again.

clock

the Clock to use for localization. By default, it collects SYSTEM_CLOCK, so any clock change is immediately reflected

timeZone

the TimeZone to use for localization. By default, it collects SYSTEM_TIMEZONE, so any timezone change is immediately reflected

maxTick

the maximum amount of to wait for a recomputation (as long as this underlying provider returns a non-null TickingValue.nextTick). If null (the default), no max tick bound is applied.