Created
February 19, 2020 02:53
-
-
Save ilhamgusti/f4f276b6dbffb5f7fdadb8353f6ff30c to your computer and use it in GitHub Desktop.
menunda event berjalan. menjalankan event ketika sekian detik aksi
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
function debounced(delay, fn) { | |
let timerId; | |
return function (...args) { | |
if (timerId) { | |
clearTimeout(timerId); | |
} | |
timerId = setTimeout(() => { | |
fn(...args); | |
timerId = null; | |
}, delay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment