tuil
Concepts

Events

Typed event definitions, routing phases, priorities, observation, and lifecycle events.

View rawEdit

Events are declared before emission. This keeps plugin and application event maps type-safe and gives observers a single redaction boundary.

const events = defineEvents({
  "task:started": event<{ taskId: string }>(),
  "credential:used": event<{ token: string }>({
    redact: () => ({ token: "[redacted]" }),
  }),
});

Core application events

EventMeaning
app:configureThe application boundary and definitions exist.
app:initializeServices and plugins are initializing.
app:mountThe renderer is attaching.
app:readyThe application accepts normal interaction.
app:errorA runtime phase reported an error.
app:stopTeardown has started.
app:disposeOwned resources are disposed.

Dispatch flow

Documentation flow diagram. emit(type, payload) leads to definition exists; Validate leads to priority scheduling; Schedule leads to capture path; Capture leads to target; Target leads to bubble path; Bubble leads to redact observed payload; Redact leads to bounded history; History leads to diagnostics and devtools
Documentation flow diagram. emit(type, payload) leads to definition exists; Validate leads to priority scheduling; Schedule leads to capture path; Capture leads to target; Target leads to bubble path; Bubble leads to redact observed payload; Redact leads to bounded history; History leads to diagnostics and devtools

preventDefault() records that default behavior should not run. stopPropagation() ends the remaining routed phases. Subscription priority orders listeners within the same phase; event priority controls scheduling.

Priorities

  • immediate: lifecycle and safety-sensitive work
  • interaction: direct user intent
  • normal: ordinary application updates
  • background: work that may yield before dispatch

Subscription ownership

on() and observe() return disposers. Pass an AbortSignal when the subscription belongs to a request, workflow step, plugin activation, or React effect so cancellation and disposal share the same boundary.

Workflow and router event vocabularies are listed in their package pages.

On this page