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
npm package (v2.0.3) cancel() kills the function #111
Comments
Thanks for let me know! It should be released long time ago. I have just published the latest version. Let me know whether the issue still exists. |
Thank you. However, I ended up copying the code and extending it for our use. In particular, I added
I also added an If you want I could open pull requests for some or all of these? |
Oh, I did not know the |
Yeah, essentially it's just a flag: const later = context => () => {
requestId = null;
if (!stopped) {
callback.apply(context, lastArgs);
}
};
const throttled = function(...args) {
lastArgs = args;
if (requestId === null && !stopped) {
requestId = requestAnimationFrame(later(this));
}
};
// ...
throttled.stop = () => {
stopped = true;
lastArgs = undefined;
throttled.cancel();
};
throttled.start = () => {
stopped = false;
}; |
Thanks for sharing 👍 |
In the latest version on npm (2.0.3) the cancel function does not unset the
requestId
, unlike the currentmaster
branch. If it is called while a raf call is queued, it effectively terminates the function permanently. Could you please publish a new version to npm?The text was updated successfully, but these errors were encountered: