atlassian / react-sweet-state

Shared state management solution for React
https://atlassian.github.io/react-sweet-state/
MIT License
871 stars 55 forks source link

Batch notify #104

Closed albertogasparin closed 4 years ago

albertogasparin commented 4 years ago

When we have multiple update to same store or different stores, it was hard to batch them, especially if triggered as useEffect on multiple components.

This batched implementation allows components to be notified of updates to the same store at the same time if the change of state happens in the same tick. It causes the re-render to be no longer sync but scheduled, however given react partially batches already it's just happening earlier. One possible downside is that in case of long tasks the update might come later.

In case of problems can be disabled globally with defaults.batchUpdates = false