Created
January 16, 2019 12:22
-
-
Save ronakjain2012/380feebd6b0d23b3738d8d57ef3521ba to your computer and use it in GitHub Desktop.
Call any function after a delay
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
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