Skip to content

Instantly share code, notes, and snippets.

@ronakjain2012
Created January 16, 2019 12:22
Show Gist options
  • Save ronakjain2012/380feebd6b0d23b3738d8d57ef3521ba to your computer and use it in GitHub Desktop.
Save ronakjain2012/380feebd6b0d23b3738d8d57ef3521ba to your computer and use it in GitHub Desktop.
Call any function after a delay
const debounce = (func, delay) => {
let inDebounce
return function() {
const context = this
const args = arguments
clearTimeout(inDebounce)
inDebounce = setTimeout(() => func.apply(context, args), delay)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment