Created
October 29, 2019 15:49
-
-
Save jarretmoses/d9166ac2d429d404230d8f4de9ca54c1 to your computer and use it in GitHub Desktop.
Debounce from Scratch
This file contains 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
const debounce = (callback, wait) => { | |
let timeout = null; | |
return (...args) => { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => { | |
callback.apply(this, args); | |
}, wait); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment