Skip to content

stopTimer

stopTimer takes the timer off a component. It is how an onTimer handler stops itself.

stopTimer(target: ComponentId): void
src/boost.ts2
<text x={28} y={4} w={120} h={14} text="Strength boost" font={Fonts.PLAIN}
valign="middle" shadow color={Colors.WHITE}
transparency={(FADE_STEPS - step) * 10}
onTimer={(event) => {
if (step >= FADE_STEPS) { stopTimer(event.self); } else { setStep(step + 1); }
}} />
  • target: Anything that names a component — a ref, a ComponentId parameter, or event.self, which is the component the timer fired on.

Nothing.

  • A timer has no interval and no end. onTimer fires every client cycle until something clears it; a handler that should not run forever checks its deadline and stops itself.
  • A timer set by useInterval or useDelay is usually stopped through the Timer those return — tick.stop().
src/boost.ts2
if (step >= FADE_STEPS) { stopTimer(event.self); } else { setStep(step + 1); }

Call stopTimer(event.self) when it finishes.