SetInterval runs actions on a repeating timer. Each tick fires on_tick, and the timer stops automatically when a while_ condition becomes false, a count limit is reached, or both. When it stops, on_complete fires one final time.
One-Shot Delay
Setcount=1 to fire once after a pause — no separate “delay” action needed. Put your logic in on_complete and it runs when the timer finishes. The button below swaps to a waiting state so the user knows something is happening.
Countdown
Each tick decrementsseconds in state, and the display reflects the current value through reactive expressions. When seconds reaches zero, the while_ condition becomes false and the interval stops on its own.
Start and Stop
Store a boolean flag in state and reference it inwhile_. Any action can flip the flag — the interval checks it on the next tick and stops. Here, one button starts an incrementing counter and another stops it. The same pattern works for periodic server polling with CallTool in on_tick.
If neither while_ nor count is set, the interval runs indefinitely until the component tree is replaced.
API Reference
SetInterval Parameters
Milliseconds between ticks. Passed as a positional argument.
Condition expression re-evaluated each tick against current state. When
it evaluates to falsy, the interval stops and
on_complete fires. Serializes
as "while" on the wire.Maximum number of ticks. The interval stops after this many.
Action(s) to run each tick.
$event is the tick number (1, 2, 3, …).Action(s) to run when the interval finishes.
Protocol Reference
SetInterval