collect
suspend fun <T> TickingValueProvider<T>.collect(clock: Clock, timeZone: TimeZone, maxTick: Duration? = null, initialReference: Zoned<Instant> = Zoned(clock.now(), timeZone), initialValue: TickingValue<T> = this.provide(initialReference), collector: suspend (T) -> Unit)
Function that calls collector with the TickingValue.value calculated by this TickingValueProvider.provide each time there is a new value.
Parameters
timeZone
the TimeZone to use for the reference point
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.
initialReference
optional parameter that allows to explicitly specify the initial value. Useful if the initial value needs to be available immediately outside of this function to avoid calculating it twice.
collector
the function that gets called once immediately initially, and then once for every subsequent TickingValue.value, delayed by each TickingValue.nextTick.