TickingValueProvider
Simple interface that allows implementors to provide a TickingValue for a given reference point.
Functions
Link copied to clipboard
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.
Link copied to clipboard
fun <T, R> TickingValueProvider<T>.map(transform: (localized: TickingValue<T>, reference: Zoned<Instant>) -> TickingValue<R>): TickingValueProvider<R>
Simple mapping function that returns a new TickingValueProvider that, upon TickingValueProvider.provide, calls transform with the result of provide and its reference point, and returns the output of transform.
Link copied to clipboard
fun <T> TickingValueProvider<T>.toFlow(clock: Flow<ClockWrapper> = SYSTEM_CLOCK, timeZone: Flow<TimeZone> = SYSTEM_TIMEZONE, maxTick: Duration? = null): Flow<T>
Uses the given clock and timeZone flows to compute the reference point passed to TickingValueProvider.provide and returns the resulting Flow. This function assumes that each Clock emitted by the clock flow moves forward linearly.