← Events and errors

Route handle events explicitly

app.handle · app.resolve · exact host payloads
action + target + value

One callback may receive unrelated UI, lifecycle, navigation, timer, and media events, so every mutation needs a narrow branch.

When to use it

Use this dispatch shape whenever an application has more than one event source.

  • action identifies the declared operation or host event family.
  • target identifies the stable UI node, timer ID, or app host target.
  • value is source-specific and may be empty; never assign it directly to trusted state without validation.
  • Ignoring an unknown event is safer than applying it to the nearest-looking state branch.

Focused example

local function handle(action: string, target: string, value: string)
    if action == "counter.add" and target == "counter/add" then
        count += 1
    elseif action == "lifecycle" and target == "app" then
        handleLifecycle(value)
    elseif action == "timer" and target == "refresh" then
        refresh(value)
    end
end

Complete inventory

View all pages in Events and errors
Next: Handle lifecycle state →