Created
August 29, 2020 19:32
-
-
Save LucasFsc/f71a8b45e9a7920b5f875552c0f658ba to your computer and use it in GitHub Desktop.
Debounce JS
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
let timer = null | |
export default (callback = () => {}, timing = 300) => { | |
if (timer) clearTimeout(timer) | |
timer = setTimeout(callback, timing) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment