localizeAsFlow

fun <T, R> PolyglotReferenceValueLocalizer<T, R>.localizeAsFlow(value: T, clock: Flow<ClockWrapper> = SYSTEM_CLOCK, timeZone: Flow<TimeZone> = SYSTEM_TIMEZONE, maxTick: Duration? = null): Flow<R>(source)

Localizes value by using the given clock's Clock.now and timeZone flows as a reference point and returns a Flow that emits updated values based on the underlying TickingValue.nextTick. This function assumes that each Clock emitted by the clock flow moves forward linearly.

The flow always immediately emits the localized value before any suspension point, assuming that clock and timeZone immediately emit a value as well.

Parameters

value

the value to localized, passed as-is to PolyglotReferenceDateTimeLocalizer.localize

clock

the Clock to use to obtain the Instant for the reference point. It is a Flow because the time might be changed (e.g. by an NTP sync or by the user manually adjusting the time). Whenever a new ClockWrapper is emitted, the localized string is recomputed. See SYSTEM_CLOCK for more info.

timeZone

the TimeZone to use for the reference point. It is a Flow because it might change (e.g. if the user crosses a time zone line). When a different time zone is emitted, the localized string is recomputed. See SYSTEM_TIMEZONE for more info.

maxTick

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