Skip to content
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

Fix c-throttle #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jesuisYves
Copy link

In the current implementation of throttle, the function to be throttled is always called with the arguments it was first called with.

When calling throttled after the timer has expired, it calls wrapped with the previous arguments, but wrapped calls throttled again with those arguments, and so there is a mutual recursion.

To prevent this we need to store the arguments for the deferred call in the outer context of throttle and wrapped.

I also changed the usage example to show that the problem was solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant