Skip to content

Instantly share code, notes, and snippets.

@kvendrik
Created April 3, 2019 19:19
Show Gist options
  • Save kvendrik/7ad06424cc47fceeb95aac5ffc37ca04 to your computer and use it in GitHub Desktop.
Save kvendrik/7ad06424cc47fceeb95aac5ffc37ca04 to your computer and use it in GitHub Desktop.
Debounce fun
function debounce(method, timing) {
let canExecute = true;
return (...args) => {
if (!canExecute) {
return;
}
method(...args);
canExecute = false;
setTimeout(() => {
canExecute = true;
}, timing);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment