Simple timer model to manage some countdown.
import { reatomTimer } from '@reatom/timer'
const pomodoroAtom = reatomTimer({
name: 'pomodoroAtom',
interval: 1000,
delayMultiplier: 1000,
progressPrecision: 2,
resetProgress: true,
})
Example: https://codesandbox.io/s/reatom-react-pomodoro-f219zu?file=/src/App.tsx
export interface TimerAtom extends AtomMut<number> {
progressAtom: Atom<number>
intervalAtom: AtomMut<number>
startTimer: Action<[delay: number], Promise<void>>
stopTimer: Action<[], void>
pauseAtom: AtomMut<boolean>
pause: Action<[], boolean>
endTimer: Action<[], void>
}