TimerMode

View source

Defines how Timer behaves when a cycle reaches its duration.

One-shot behavior stops at the duration and reports completion. Repeating behavior wraps to the next cycle and continues counting completed cycles.

Examples

import { Timer, TimerMode } from '@wimaengine/time'

const once = new Timer({ duration: 1, mode: TimerMode.Once })
once.update(1.25)
console.log(once.elapsed(), once.completed()) // 1, true

const repeat = new Timer({ duration: 1, mode: TimerMode.Repeat })
repeat.update(1.25)
console.log(repeat.elapsed(), repeat.cyclesCompleted()) // 0.25, 1

Variants


Once

View source

Complete after the first duration and remain at the duration.

Repeat

View source

Wrap at each duration and continue counting completed cycles.