Add delay(fn, timeout) Higher-Order Function#1
Conversation
…a delayed version of the given function - updated Lodash library
|
Thanks a lot Matthias, I'm sorry that I didn't reply before, I left it for "tomorrow", and I I'm thinking to update the article, because those functions have changed a I hope to do it soon. Cheers! David Corbacho On Tue, Oct 22, 2013 at 12:51 AM, Matthias Seemann <notifications@github.com
|
|
Hi David, I myself have postponed a write up of this topic for some time now. Hope I can carve out some free time to do it. In the mean time I reviewed my pull request and found two things:
function delay(f, dt){
return function(){
setTimeout.apply(window, [f, dt].concat(Array.prototype.slice.call(arguments, 0)));
};
}
If in the elevator analogy the Cheers! |
The explanation of debounce and throttle and the visual demo in your original blog post are just great!
I felt I really had to see my delay higher order function in that timeline. It just delays normal execution of the original function. In the elevator analogy it is a time-shifted one-person-cabin (i.e. the person travels forward in time).
Maybe it is not much, but if you do functional stuff in Javascript you can't without it. It is missing from Lodash's function utilities, so I have to start my own collection…
Thank you for the demo