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
Suggestion: add features from Ben Alman's throttle/debounce plugin #91
Comments
Perhaps -- can you share a real world example where they come in handy? I can't think of any off the top of my head... |
Well, throttling and debouncing are quite abstract concepts of course, so there are countless scenarios. I believe the parameters are not a luxury as they enable use cases that are otherwise simply not possible. I can give you an example from my own work, although I'm not sure if it's really helpful: I'm using debouncing to make sure that AJAX requests are not being issued more than four times per second, like so (Alman's API): Alas, not sure if this makes sense to an outsider. I could also bounce the question; if you can tell how to achieve the same effect (of |
If you end up wanting this in Underscore, I'd be happy to contribute the code, just let me know. |
cowboy: Thanks for the kind offer. timmolendijk: I just mostly want to wrap my head around the use cases first... Let me try to play Devil's advocate: You don't need You don't need |
While debouncing is very commonly used for rate-limiting AJAX requests resulting from text entry, it can be used in other ways. For example, imagine that you have a game where responsiveness is critical, but the gamer must be prohibited from triggering an action more than once, until some kind of inactivity threshold has been met. Using the The I'm not suggesting in any way that Underscore should attempt to handle these scenarios, just that they are possibly valid for users of a generalized Throttle/Debounce library (which is what my plugin tries to be). |
While in the case of rate-limiting AJAX requests resulting from text entry, what you want is |
It seems these got included into Underscore — should this issue be closed? |
Nice! Hadn't noticed yet. Yeah I think this resolves my issue. Thx |
I am looking at the definitions for throttle and debounce in the source for the development version of Underscore 1.1.5 and I don't see the features. Am I looking in the wrong place? |
I was looking e.g. http://documentcloud.github.com/underscore/#throttle |
I see the descriptions of |
@mikez302: |
What about Also, just because it is possible to implement these features myself, is that a reason not to include them in underscore? In theory, I can implement all the features in underscore myself. |
i was just looking for the no_trailing option for throttle. but its not there. |
See http://benalman.com/projects/jquery-throttle-debounce-plugin/
The
no_trailing
andat_begin
parameters are extremely useful and I'd love to see them added to Underscore'sthrottle
anddebounce
functions.The text was updated successfully, but these errors were encountered: