Skip to content

Instantly share code, notes, and snippets.

@bekliev
Forked from lstanard/waitForFinalEvent()
Last active March 10, 2020 01:56
Show Gist options
  • Save bekliev/2104b5398c2f4ca66861 to your computer and use it in GitHub Desktop.
Save bekliev/2104b5398c2f4ca66861 to your computer and use it in GitHub Desktop.
debounce ES6
// 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