Created
December 11, 2018 14:26
-
-
Save olecksamdr/c98acf60fbf0c1cd9378dd3fe3d167e8 to your computer and use it in GitHub Desktop.
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
// debounce :: Number -> (Args -> Any) -> (Args -> Undefined) | |
// Args = Any | |
export const debounce = time => (fn) => { | |
let timeout; | |
return (...args) => { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => fn(...args), time); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment