timer
Timer model to manage some countdown. Useful for classic pomodoro or any time-progress states, like notifications.
The timer itself contains the ms remaining to the end of the timer (0
before start). Here is the list of available states and methods:
- progressAtom (
Atom<number>
) - from 0 to 1,(delay - remains) / delay
- intervalAtom (
AtomMut<number>
) - interval of ticks in ms - startTimer (
Action<[delay: number, passed?: number], Promise<void>>
) - start timer with the delay and optional start point - stopTimer (
Action<[], void>
) - stop timer manually - pauseAtom (
AtomMut<boolean>
) - allow to pause timer - pause (
Action<[], boolean>
) - switch pause state - endTimer (
Action<[], void>
) - track end of timer. Do not call manually!