Skip to content

Instantly share code, notes, and snippets.

@akosiyawin
Created June 20, 2022 01:50
Show Gist options
  • Save akosiyawin/6e5c333a0fc098760f5d755ec91b9b4a to your computer and use it in GitHub Desktop.
Save akosiyawin/6e5c333a0fc098760f5d755ec91b9b4a to your computer and use it in GitHub Desktop.
Global function for debouncing
//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