# Events

Source: /tuil/docs/concepts/events
Locale: en

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



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

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

## Core application events [#core-application-events]

| Event            | Meaning                                         |
| ---------------- | ----------------------------------------------- |
| `app:configure`  | The application boundary and definitions exist. |
| `app:initialize` | Services and plugins are initializing.          |
| `app:mount`      | The renderer is attaching.                      |
| `app:ready`      | The application accepts normal interaction.     |
| `app:error`      | A runtime phase reported an error.              |
| `app:stop`       | Teardown has started.                           |
| `app:dispose`    | Owned resources are disposed.                   |

## Dispatch flow [#dispatch-flow]

<Mermaid
  chart="flowchart LR
  Emit[&#x22;emit(type, payload)&#x22;] --> Validate[&#x22;definition exists&#x22;]
  Validate --> Schedule[&#x22;priority scheduling&#x22;]
  Schedule --> Capture[&#x22;capture path&#x22;]
  Capture --> Target[&#x22;target&#x22;]
  Target --> Bubble[&#x22;bubble path&#x22;]
  Bubble --> Redact[&#x22;redact observed payload&#x22;]
  Redact --> History[&#x22;bounded history&#x22;]
  History --> Observers[&#x22;diagnostics and devtools&#x22;]"
/>

`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 [#priorities]

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

## Subscription ownership [#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](/tuil/docs/reference/packages).
