Last active
December 19, 2019 15:01
-
-
Save kettanaito/ecbaf6f51856cfa1b986bef6a8027075 to your computer and use it in GitHub Desktop.
Debounce
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
function debounce(func, duration) { | |
let timeout | |
return (...args) => { | |
const effect = () => { | |
timeout = null | |
return func(...args) | |
} | |
clearTimeout(timeout) | |
timeout = setTimeout(effect, duration) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment