class Rooibos::Command::Wait
A one-shot timer command.
Applications need timed events. Notification auto-dismissal, debounced search, and animation frames all depend on delays. Building timers from scratch with threads is error-prone. Cancellation is tricky.
This command waits, then sends a message. It responds to cancellation cooperatively. When canceled, it sends Message::Canceled so you know the timer stopped.
Use it for delayed actions, debounced inputs, or animation loops.
Prefer the Command.wait or Command.tick factory methods for convenience. Both are aliases for the same behavior.
Example: Notification dismissal
def update(msg, model) case msg in :save_clicked [model.with(notification: "Saved!"), Command.wait(3.0, :dismiss)] in :dismiss [model.with(notification: nil), nil] in Message::Canceled [model.with(notification: nil), nil] # User navigated away end end
Example: Animation loop
def update(msg, model) case msg in :start_animation [model.with(frame: 0), Command.tick(0.1, :animate)] in :animate frame = (model.frame + 1) % 10 [model.with(frame:), Command.tick(0.1, :animate)] end end