-
Notifications
You must be signed in to change notification settings - Fork 177
Debounce of the digests triggered by store modification #175
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
Conversation
@@ -41,6 +41,13 @@ export default function ngReduxProvider() { | |||
_initialState = initialState || {}; | |||
}; | |||
|
|||
this.config = { | |||
debounce: { | |||
wait: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we do a default debounce of 1ms, would it be possible for us to batch updates "per tick" essentially? I'm thinking of how you might queue several actions at the same time and instead of digesting each one immediately, we'd let it all run on the next tick/frame/whatever.
I'm not sure if $evalAsync does this already or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "per tick" should be already covered by the $evalAsync
.
I think that 1ms won't make a real performance gain.
Here we set it to {wait: 100, maxWait: 500}
for a gain of ~50% of digests.
@jtassin this is fantastic functionality! I'd like to add this ASAP. Can you look over it once more? I definitely let this one linger for way too long. |
README.md
Outdated
// eslint-disable-next-line | ||
$ngReduxProvider.config.debounce = { | ||
wait: 100, | ||
mawWait: 500, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a typo here, I assume this is intended to be maxWait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, thx for review.
It's corrected.
capability for ngRedux to debounce the digests
The problem
In my huge app, I have a lot of stimulations that modify the store and each one lead to a digest (via $rootScope.$evalAsync). The accumulation of digests considerably affect the performance of the application.
Solution
We added a use of lodash.debounce in the digest middleware to avoid digesting too much.
Content of the PR
Use of the fonctionnality in my app
last but not least
Thx for your usefull lib ;-)