Created
November 27, 2020 01:54
-
-
Save the-glima/edc1f6559224c9a169a9a4502cf5bb62 to your computer and use it in GitHub Desktop.
Debounce
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: Function, delay: number) => { | |
let timeout: any; | |
return (...args: any) => { | |
clearTimeout(timeout) | |
timeout = setTimeout(() => { | |
timeout = null | |
callback(...args) | |
}, delay) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment