Primitives / foldkit-primitives/time
Timer
const · packages/primitives/src/time/timer.ts:22
| Args | { intervalMs: number } |
|---|---|
| Model | { count: number, running: boolean } |
| Messages | Started, Stopped, Ticked |
Its full type
const Timer: Bundle.Bundle<
'Timer',
{ readonly intervalMs: number },
{ readonly count: number; readonly running: boolean },
| { readonly _tag: 'Started' }
| { readonly _tag: 'Stopped' }
| { readonly _tag: 'Ticked' },
never,
never,
never,
void,
{},
{}
>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
- Which form a primitive takesPrimitives / foldkit-primitives
- Find one by the jobPrimitives / foldkit-primitives
- The mapPrimitives / foldkit-primitives
- foldkit-primitives/timePrimitives / Time
- Start with one: a timerPrimitives / Time
- ticks: a clock the Model drivesPrimitives / Time