Created
April 3, 2019 19:19
-
-
Save kvendrik/7ad06424cc47fceeb95aac5ffc37ca04 to your computer and use it in GitHub Desktop.
Debounce fun
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
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