-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.0.5 fork #3836
4.0.5 fork #3836
Conversation
Appreciate the PR, but there's no need to modify the core for this. Multiple addons already offer this functionality, like https://redux.js.org/faq/performance#how-can-i-reduce-the-number-of-store-update-events |
Deploy preview for redux-docs ready! Built with commit 43dbc6f |
Hi @markerikson , thanks for your quick response. Using the addons you've mentioned can I skip calling the listeners completely? Do I need to do it on every place explicitly in the code? |
Store enhancers like The React-Redux |
Hey @markerikson, I looked at the redux_batched_subscribe as you suggested. It seems like they override the internal logic (subscribe) of redux, and it seems like they've copied from an old branch of redux. It also means that if I'll use their package, I no longer receive updates of the logic of subscribe/unsubscribe if you change it in the future. (i.e. they are missing the memory cleanup that was made in 4.0.5 after unsubscribe. Maybe we should have an option to pass a middleware that will wrap notify subscribers. |
The point of the enhancer API is to allow addons to override and provide their own implementations of the core store API ( https://blog.isquaredsoftware.com/2017/09/presentation-might-need-redux-ecosystem/ That contract does not let enhancers see the internals of the existing APIs from the lower-level store being wrapped. In addition, the actual store implementation knows nothing about "frames". The core We're not modifying the core store implementation for this use case. Given how rarely the store API actually changes, I don't see a need to try to provide an override point just for enhancers to pick up any hypothetical future tweaks to the dispatching logic. That's especially true since the point of an enhancer is that it's going to provide its own implementation of The addons I've linked already allow you to solve your use case, in varying ways. You should probably also read my post A Comparison of Redux Batching Techniques, which discusses when it might make sense to use each of those approaches. For reference, there were some discussions back in 2016-ish about hypothetical modifications to the enhancer definition to allow splitting that logic into smaller overridable pieces, but those PRs stalled and we eventually closed them due to lack of progress and lack of actual interest. See these prior issues/PRs: |
Allow configure the store to notify listeners (store's subscribers) only once per frame and not on every dispatch.
For example let say I have 10 dispatches on the same frame (i.e. one function that calls 5 dispatches and each one of them calls another dispatch). Instead of running the listener on every dispatch, I want to be able to run them only once after all dispatches are over (for performance).