I have a lot of components that update every seconds based on Date.now(). However, performing these updates through the redux stores makes dev-tools and logging extremely slow, spammed and unusable.
Does anyone have any suggestions on how one can handle this in the best way?
One way I was thinking about was that the components themselves have a time subscription that calls setState with the current time, i.e. time updates are local to the component. The time has (mostly) no logical meaning only visual.
How are you using time in your reducers? Since time is an external state, and introduces non-pure effects into store, it should probably be kept external. If you're using React, I would handle it internal to your components.
Say, for example, you have a list of comments on a blog and you want to have the timestamp next to each comment update in real time ("1 minute ago" changes to "2 minutes ago", etc.). I wouldn't track that in my redux store, as that's a display concern. I would either have each comment component set up a setInterval and re-render as needed. Or I would set that up at the top level comment list container and pass down the current time as a prop to each comment component and have them re-render as needed.
Sounds reasonable. Thank you for the feedback.
Most helpful comment
How are you using time in your reducers? Since time is an external state, and introduces non-pure effects into store, it should probably be kept external. If you're using React, I would handle it internal to your components.
Say, for example, you have a list of comments on a blog and you want to have the timestamp next to each comment update in real time ("1 minute ago" changes to "2 minutes ago", etc.). I wouldn't track that in my redux store, as that's a display concern. I would either have each comment component set up a
setIntervaland re-render as needed. Or I would set that up at the top level comment list container and pass down the current time as a prop to each comment component and have them re-render as needed.