Skip to content

Instantly share code, notes, and snippets.

@mattiaerre
Created July 29, 2016 19:08
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 mattiaerre/dba945a18435685c49d7613e92e46816 to your computer and use it in GitHub Desktop.
Save mattiaerre/dba945a18435685c49d7613e92e46816 to your computer and use it in GitHub Desktop.
handle-change-with-debounce.js
handleChange(e) {
e.persist();
// info: "this.debounced" is defined at the class level
if (!this.debounced) {
this.debounced = _.debounce(() => {
console.log('YATTA!');
this.debounced.cancel();
this.debounced = undefined;
}, 500);
this.debounced();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment