Skip to content

Instantly share code, notes, and snippets.

@the-glima
Created November 27, 2020 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-glima/edc1f6559224c9a169a9a4502cf5bb62 to your computer and use it in GitHub Desktop.
Save the-glima/edc1f6559224c9a169a9a4502cf5bb62 to your computer and use it in GitHub Desktop.
Debounce
const debounce = (callback: Function, delay: number) => {
let timeout: any;
return (...args: any) => {
clearTimeout(timeout)
timeout = setTimeout(() => {
timeout = null
callback(...args)
}, delay)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment