-
-
Save Takaitra/78021a60e3ba75a8bcdfd20c0cec06bd to your computer and use it in GitHub Desktop.
ES6 Debounce function
This file contains hidden or 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
| export function debounce (func, delay = 500) { | |
| let timeout; | |
| return function (...args) { | |
| clearTimeout(timeout); | |
| timeout = setTimeout(() => { func.apply(this, args) }, delay); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment