blob: 77d99a894ce9fbda77a98d5c34301efa138481e0 (
plain) (
tree)
|
|
export function Debounce (config: { timeoutMS: number }) {
let timeoutRef: NodeJS.Timeout
return function (_target, _key, descriptor: PropertyDescriptor) {
const original = descriptor.value
descriptor.value = function (...args: any[]) {
clearTimeout(timeoutRef)
timeoutRef = setTimeout(() => {
original.apply(this, args)
}, config.timeoutMS)
}
}
}
|