DEV Community

Discussion on: Building todometer: a meter-based to-do list

Collapse
 
mpjme profile image
Mattias P Johansson

Whenever I need to deal with time in redux, I generally set up an Action that uses setInterval to dispatch another action every 100ms or to Redux with the current time, which updates the reducer state with the current time. That way, time becomes completely reactive and declarative and updates work fine. The action is started from componentDidMount.

Collapse
 
cassidoo profile image
Cassidy Williams

That's a good idea to have it live in the action.

That being said, I didn't want to just check for the time every second (or so), I wanted to just set a countdown to midnight and let the app refresh from there.

That being said, thank you, that'll be really helpful for when I do something like that outside of Electron!