Created
January 23, 2018 03:13
-
-
Save Jon-Alonso/1862823bd4ddd59cd770b4b42fe8b804 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 () { | |
| clearTimeout(timeout) | |
| timeout = setTimeout(() => { func.apply(this, arguments) }, delay) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment