stopTimer
stopTimer takes the timer off a component. It is how an onTimer handler
stops itself.
stopTimer(target: ComponentId): voidReference
Section titled “Reference”stopTimer(target)
Section titled “stopTimer(target)” <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); } }} />Parameters
Section titled “Parameters”target: Anything that names a component — a ref, aComponentIdparameter, orevent.self, which is the component the timer fired on.
Returns
Section titled “Returns”Nothing.
Caveats
Section titled “Caveats”- A timer has no interval and no end.
onTimerfires every client cycle until something clears it; a handler that should not run forever checks its deadline and stops itself. - A timer set by
useIntervaloruseDelayis usually stopped through theTimerthose return —tick.stop().
Stopping the timer that fired
Section titled “Stopping the timer that fired” if (step >= FADE_STEPS) { stopTimer(event.self); } else { setStep(step + 1); }Troubleshooting
Section titled “Troubleshooting”My fade keeps running after it finished
Section titled “My fade keeps running after it finished”Call stopTimer(event.self) when it finishes.