Created
June 20, 2022 01:50
-
-
Save akosiyawin/6e5c333a0fc098760f5d755ec91b9b4a to your computer and use it in GitHub Desktop.
Global function for debouncing
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
//Use this to your reactive data/state. | |
function debounce(Callback, delay = 500) { | |
if (typeof window.DEBOUNCER !== 'undefined') { | |
clearTimeout(window.DEBOUNCER); | |
} | |
window.DEBOUNCER = setTimeout(() => { | |
Callback(); | |
}, 500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment