classic-ui/utils/debounce.js

18 lines
361 B
JavaScript
Raw Normal View History

2022-04-22 06:05:56 +03:00
export const _debounce = (func, waitFor) => {
let timeout = null
const debounceFunction = (...args) => {
if (timeout) {
clearTimeout(timeout)
timeout = null
}
timeout = setTimeout(() => {
return func(...args)
}, waitFor)
}
return debounceFunction
}
export const debounce = _debounce((func, args) => func(args), 400)