Created
July 29, 2016 19:08
-
-
Save mattiaerre/dba945a18435685c49d7613e92e46816 to your computer and use it in GitHub Desktop.
handle-change-with-debounce.js
This file contains hidden or 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
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