Created
February 25, 2020 14:33
-
-
Save median-man/c9d5c46fddac9c44638e9cc2241e41c8 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
/* | |
Simple, no frills, debounce function. | |
*/ | |
const debounce = (func, waitMs) => { | |
let timeout; | |
return () => { | |
if (timeout) { | |
clearTimeout(timeout); | |
} | |
timeout = setTimeout(func, waitMs); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment