Skip to content

Instantly share code, notes, and snippets.

@balsanka
Created June 11, 2022 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balsanka/0d6eee9f1fcb57ef002340df68068ca4 to your computer and use it in GitHub Desktop.
Save balsanka/0d6eee9f1fcb57ef002340df68068ca4 to your computer and use it in GitHub Desktop.
function debouncer(callBack, timer) {
let timeoutId;
return function () {
let context = this;
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
callBack.apply(context, arguments);
clearTimeout(timeoutId);
}, timer);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment