-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Single call option? #3
Comments
Same problem, I'd gladly hear some recommendation. In particular I'd like debounced promise where any new promise issue cause all running promises to be cancelled and chain is replaced by last issued promise. So something like this: const expensiveCall = input => new Promise((resolve) => setTimeout(resolve, 1000))
const debouncedFn = pDebounce(expensiveCall, 200, { leading: true });
for (const i of [1, 2, 3]) {
debouncedFn(i).then(console.log);
}
//=> 3 |
I agree, this could be useful. PR welcome if someone can come up with a good option name and behavior. |
Promises can't be cancelled.
|
|
I would like to debounce a function returning a promise but also limit the concurrent calls of my function to 1. That is, if a previous invocation is still running after the debounce delay is reached, delay again and again... until the last call finish and the debounce delay is expired (no other calls occured during the waiting time).
I know you also developed another module to limit conccurency, but I don't think I can combine it with this one to obtain the behavior I need. In my use case (an async database update), it's important that the last call occur ;)
The text was updated successfully, but these errors were encountered: