防抖装饰器

debounce

class Test {
times = 0;
time = 0;
value: string | number = '';

@Debounce(1000)
test(value: string | number) {
this.times++;
this.time = Date.now();
this.value = value;
}
}

const t = new Test();

t.test(1);
t.test(2);
t.test(3);
t.test(4);
  • 参数

    • 动态参数...args: [delay: number, leading: boolean]

    返回 ((target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void)

      • (target, _propertyKey, descriptor): void
      • 参数

        • target: any
        • _propertyKey: string
        • descriptor: PropertyDescriptor

        返回 void