Primitives / foldkit-primitives/time
Timer
const · packages/primitives/src/time/timer.ts:22
| Args | { intervalMs: number } |
|---|---|
| Model | { count: number, running: boolean } |
| Messages | Stopped, Started, Ticked |
Its full type
const Timer: Bundle.Bundle<
'Timer',
{ readonly intervalMs: number },
{ readonly count: number; readonly running: boolean },
| { readonly _tag: 'Stopped' }
| { readonly _tag: 'Started' }
| { readonly _tag: 'Ticked' },
never,
never,
never,
NoView,
{},
{},
undefined
>A timer as a bundle: a count in the Model, advanced by a tick stream while
running. The clock is Effect's, so tests drive it with TestClock instead of
waiting. For a clock whose running or interval the parent's Model decides,
use the ticks entry instead.
In the guides
- foldkit-primitivesPrimitives / foldkit-primitives
- Find a primitive by taskPrimitives / foldkit-primitives
- Subpaths by concernPrimitives / foldkit-primitives
- foldkit-primitives/timePrimitives / Time
- Start with one: a timerPrimitives / Time
- ticks: a clock the Model drivesPrimitives / Time