← Events and errors

Handle lifecycle state

app.handle · app.resolve · exact host payloads
handle("lifecycle", "app", value)

The current hosts emit launch, foreground/background visibility, and online/offline connectivity as serialized application events.

When to use it

Use lifecycle events for resumable state and user-visible connectivity, not as proof that a remote request succeeded.

  • Initial web delivery is launch, current visibility, then current connectivity.
  • Native app-state integration emits launch and current foreground/background state, followed by connectivity.
  • Repeated pending equivalents may be deduplicated; code must not depend on duplicate delivery.
  • Background is a state transition, not permission to promise unrestricted background execution.

Focused example

if action == "lifecycle" and target == "app" then
    if value == "launch" then
        status = "Starting"
    elseif value == "foreground" then
        status = "Visible"
    elseif value == "background" then
        status = "Background"
    elseif value == "online" then
        connectivity = "online"
    elseif value == "offline" then
        connectivity = "offline"
    end
end

Complete inventory

View all pages in Events and errors
← Previous: Route handle events explicitlyNext: Decode a system Back intent →