# Events

Distinguish committed decisions from preference drafts and navigation.

Source: https://docs.peax.co/consent/reference/events



All messages arrive through `onMsg`. The complete union is generated on the [Banner API page](/consent/reference/banner).

| Type                   | Additional payload     | Application action                                                          |
| ---------------------- | ---------------------- | --------------------------------------------------------------------------- |
| `on_accept_all`        | None                   | Construct allowed choices, persist, enforce, close                          |
| `on_reject_all`        | None                   | Retain required choices, reject optional choices, persist, enforce, close   |
| `on_apply_preferences` | `preferences`          | Commit the selected category map and close                                  |
| `on_change_preference` | `sectionId`, `checked` | Observe a draft edit; do not commit                                         |
| `on_open_preferences`  | `source`               | Set `isOpen` to `true` when the source is `floating-button`                 |
| `on_close_preferences` | `source`               | Set `isOpen` to `false` when the source is `floating-button`; do not commit |

Apply includes disabled sections and can emit an unchanged selection. An empty section list produces an empty map. Decision messages leave the view open until the application updates `isOpen`.

Navigation messages identify their source as `banner` or `floating-button`. Navigation from the banner changes its internal view; floating-button navigation requests application-controlled visibility:

```tsx
if (msg.type === 'on_open_preferences' && msg.source === 'floating-button') {
  setOpen(true)
}
if (msg.type === 'on_close_preferences' && msg.source === 'floating-button') {
  setOpen(false)
}
```

Keep handling Accept, Reject and Apply separately to commit choices. Close and Escape discard drafts without granting consent.
