轮询装饰器

polling

class Test {
times = 0;

@Polling(10, true)
test(times?: number) {
this.times = times as number;
if ((times as number) >= 5) {
return Promise.reject();
} else {
// console.log(times);
return Promise.resolve();
}
}
}

const t = new Test();

await t.test();

t.times; // 5
  • 参数

    • 动态参数...args: [interval: number, immediate: boolean]

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

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

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

        返回 void