Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created December 11, 2013 10:23
Show Gist options
  • Save zapthedingbat/7908110 to your computer and use it in GitHub Desktop.
Save zapthedingbat/7908110 to your computer and use it in GitHub Desktop.
Debouncer Only executes the most recent call after the specified timeout.
// Only executes the most recent call after the specified timeout.
function Debouncer() {
var timeout;
this.execute = function(callback, wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
timeout = setTimeout(callback, wait);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment