节流装饰器

throttle

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

@Throttle(100)
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: [interval: number, options: {
          invalidCB?: ((timeCountDown: number) => void);
          trailing?: boolean;
          leading?: boolean;
      }]

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

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

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

        返回 void