Open VovanR opened 6 years ago
Timer create delete - delete timer and all child timers
start pause stop
timer end - play sound; start child timer
// @flow
const TIMER_STATUS: {
[string]: string
} = {
PLAYING: 'playing',
PAUSED: 'paused',
STOPPED: 'stopped',
ENDED: 'ended',
}
type TimerStatus = $Keys<typeof TIMER_STATUS>;
const timer: {
id: number, // uniq id
parentId: number | null, // parent id
startDate: Date | null, // click date
duration: number, // ms
progress: number, // ms calculated `nowDate - startDate`
status: TimerStatus,
} = {
id: 1,
parentId: null,
startDate: new Date('Fri Nov 03 2017 21:03:31 GMT+0300 (MSK)'),
duration: 3600,
progress: 0,
status: TIMER_STATUS.STOPPED,
}
Calculate progress in rAF
Save store in LocalStorage
?
Resume timers on browser reopened
Detect paralell browser tabs
Use notifications?
Build with react-create-app
TDD