-
-
Save bekliev/2104b5398c2f4ca66861 to your computer and use it in GitHub Desktop.
debounce ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run callback with delay | |
const debounce = (delay, callback) => { | |
let timer; | |
return function() { | |
if (timer) clearTimeout(timer); | |
timer = setTimeout(() => callback.apply(this, arguments), delay); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment