-
Notifications
You must be signed in to change notification settings - Fork 511
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
add Function.debounce #2720
base: master
Are you sure you want to change the base?
add Function.debounce #2720
Conversation
this is useful but I don't think the api is consistent. I'd go for args of fn, delay, context= to be more like .delay - don't like lodash keeps it simple by just first two On Friday, June 5, 2015, Sergio Crisostomo [email protected] wrote:
Dimitar Christoff "JavaScript is to JAVA what hamster is to ham" |
Firstly, we already have this in More for events, called "throttle", which is the main use of this, I'd guess: Regarding the API, I don't think an object as argument is a good idea. I agree with Dimitar, all it'd need is a "delay". I don't quite understand what the "early" or "once" things should do. |
nice input @DimitarChristoff and @timwienk ! Note that the configuration object idea is optional, not passing it would fall back to default (fire late & 250ms delay). @timwienk the debounce idea is different than throttle. The idea is to not fire during a serie of close event calls. Throttle will fire "periodically" during the series of events, debounce can fire just once per series of close event calls.
^ striked-out text referred to stuff not in the PR anymore |
@DimitarChristoff made it more simple now. Thoughts? |
0636d40
to
cf32346
Compare
cf32346
to
13a2199
Compare
New feature suggestion: Function.debounce.
(related: #2694)
(edited to reflect the current simplified version)
This method will return a new function that will be called only once per group of close calls. After a defined delay it will be able to be called again.
Syntax:
Arguments:
Returns:
Examples:
Comments are welcome.
If you think this is not suitable for Core let me know too.