Created
April 30, 2020 18:17
-
-
Save leonidkuznetsov18/0041ec400cf243d59a8ef13b28882e44 to your computer and use it in GitHub Desktop.
simple debounce
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
| const debounce = (fn, wait = 1) => { | |
| let timeout = 0; | |
| return function (...args) { | |
| clearTimeout(timeout); | |
| timeout = setTimeout(() => fn.call(this, ...args), wait) | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment