@meld-ts/core
    Preparing search index...

    Function createTimer

    • 创建带前缀的 timer 实例(setTimeout)

      自动给 key 加前缀,避免不同模块间的 key 冲突。 clearAll() 只清自己前缀下的定时器,不影响其他实例。

      set() 返回一个清除函数,可直接用于组件卸载等场景, 无需通过 key 查找。

      Type Parameters

      Parameters

      • OptionalprefixOrOptions: string | TimerOptions<Mode> | null

        — key 前缀(字符串)或 timer 配置。

      • mode: Mode = ...

        — 模式,timeout/interval/自定义模式

      Returns TimerHandle

      const t = createTimer('api');

      const stopPoll = t.set('poll', () => fetch('/status'), 5000);
      stopPoll(); // 或 t.clear('poll')
      t.clearAll(); // 只清 'api:*'