Simple timer model to manage some countdown.
import { reatomTimer } from '@reatom/timer'
const pomodoroAtom = reatomTimer({
name: 'pomodoroAtom',
interval: 1000,
delayMultiplier: 1000,
progressPrecision: 2,
})
Example: https://stackblitz.com/edit/reatom-timer-pomodoro?file=src%2FApp.tsx
export interface TimerAtom extends AtomMut<number> {
progressAtom: AtomMut<number>
intervalAtom: AtomMut<number> & {
setSeconds: Action<[seconds: number], number>
}
startTimer: Action<[delay: number], Promise<void>>
pauseAtom: AtomMut<boolean>
stopTimer: Action<[], void>
endTimer: Action<[], void>
}