Skip to content

Instantly share code, notes, and snippets.

@kmansoft
Created May 22, 2020 12:07
Show Gist options
  • Save kmansoft/fe0d9462302d9f705cb7474732bee91d to your computer and use it in GitHub Desktop.
Save kmansoft/fe0d9462302d9f705cb7474732bee91d to your computer and use it in GitHub Desktop.
function makeDebounce(real, interval) {
var timerValue;
return function() {
if (timerValue) {
clearTimer(timerValue)
}
timerValue = setTimer(real, interval)
}
}
function myRealFunction() {
// ...
}
foo.onchange = makeDebounce(myRealFunction, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment