RecurringTimer

class RecurringTimer(val duration: Duration, interval: Duration = 100.milliseconds, timeSource: TimeSource = TimeSource.Monotonic, delayFunction: DelayFunction = { delayDuration -> delay(delayDuration) }, coroutineScope: CoroutineScope = MainScope()) : ControllableTimer

Timer based on the system clock.

Parameters

interval

The Duration between timer ticks

timeSource

The TimeSource for measuring intervals

delayFunction

Method for delaying a given Duration

coroutineScope

a parent coroutine scope for the timer

Constructors

Link copied to clipboard
constructor(duration: Duration, interval: Duration = 100.milliseconds, timeSource: TimeSource = TimeSource.Monotonic, delayFunction: DelayFunction = { delayDuration -> delay(delayDuration) }, coroutineScope: CoroutineScope = MainScope())

Properties

Link copied to clipboard
open override val currentState: Timer.State

The current State of the timer.

Link copied to clipboard
open override val duration: Duration

timer duration

Link copied to clipboard
open override val state: Flow<Timer.State>

Flow of State of the timer.

Functions

Link copied to clipboard
suspend fun Timer.awaitFinish()

Awaits for the Timer to reach the Timer.State.NotRunning.Finished state.

Link copied to clipboard
fun Timer.elapsed(): Flow<Duration>

Duration that has elapsed while Timer.state was Timer.State.Running.

Link copied to clipboard
open suspend override fun pause()

Stops the timer.

Link copied to clipboard
open suspend override fun start()

Starts the timer.