Created
September 24, 2022 16:55
-
-
Save aydgn/ebc513b2fcd3b64d626153ab4a59e8ce to your computer and use it in GitHub Desktop.
Debounce JS
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 = (callback, wait = 1000) => { | |
| let timeoutId = null; | |
| return (...args) => { | |
| window.clearTimeout(timeoutId); | |
| timeoutId = window.setTimeout(() => { | |
| callback(...args); | |
| }, wait); | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment