jaz303 / promise-debounce

Debounce any promise-returning function so that at any instant only one call is pending
MIT License
5 stars 1 forks source link

Your semantics are wrong, you've implemented "throttle" not "debounce". #2

Open insidewhy opened 8 years ago

insidewhy commented 8 years ago

Debounce would need the ability to cancel initiated promises, a debounce should return the latest complete call.

What you have here is a throttle.

jaz303 commented 8 years ago

Thanks, I will rename the package to something more appropriate. Do you have any suggestions? promise-throttle is already taken (it has rate-limiting semantics, rather than "first wins").

insidewhy commented 8 years ago

Generally people will want to throttle according to a time period rather than due to completion of the corresponding promise and this is how throttle/debounce is implemented in every library I've used (lodash, underscore, Kefir, Bacon.js and rx.js).

To me your use case maybe feels like "atMostOneRunning" rather than "throttle" maybe.

tommyalvarez commented 7 years ago

@jaz303 i fall into this issue because i used your library thinking it did a debounce on promises :(. Rename it please or actually implement debounce instead of current behaviour