ControllableTimer

A Timer ticking a certain duration with the ability to start, pause and stop.

Inheritors

Properties

Link copied to clipboard

The current State of the timer.

Link copied to clipboard
abstract val duration: Duration

Timer Duration.

Link copied to clipboard
abstract 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
abstract suspend fun pause(): Boolean

Pauses the timer. Calling start again will make it resume.

Link copied to clipboard
abstract suspend fun start(): Boolean

Starts the timer.

Link copied to clipboard
abstract suspend fun stop()

Stops the timer causing it to finish. Calling start again will return false.