@ exodus/ timr
计时器助手类
安装
pnpm add @exodus/timer
使用量
允许固定间隔(ticks)调度任务的定时器. 它静地跟踪运行的定时器. 你可以开始、暂停、停止或清除所有任务.
开始计时器 start() 除非 delayedStart 选项。 当开始时没有 delayStart, (中文(简体) ), start() 如果 tick() 掷出. 预防 start() 失败时,请确保您妥善处理错误.
启动计时器同步
启动Async时,请确保发现任何未处理的错误.
const timer = new Timer(100)
timer.start(() => this.hello(options)).catch((err) => {})
await timer.stop()
开始计时同步
如果您需要等待第一个勾选完成, 请像这样启动计时器 :
const timer = new Timer(100)
try {
await timer.start(() => this.hello(options))
} catch (err) {}
await timer.stop()
请注意, 等待启动也等待第一个勾选完成 。 这可能会延迟启动操作,特别是长跑的滴答.