# DispatchBag

`interface` in `types` · v0.13.0

<https://docs.seedcord.org/packages/types/0.13.0/interfaces/dispatch-bag>

The read and write surface of the per-dispatch bag. `DispatchContext` in `@seedcord/core` implements it. Declared here so [`RenderContext`](/packages/types/0.13.0/interfaces/render-context) can carry one without importing the concrete class.

```ts
interface DispatchBag
```

## Properties

### id

```ts
readonly id: string
```

Unique to this one dispatch, and unique again the next time the same route runs. Every bus key this dispatch publishes carries it as `dispatchId`, so a store keyed on it lines up the dispatch, its writes, and any fault it raised.

### routeId

```ts
readonly routeId: string
```

The dispatched handler as `kind:route`, for example `slash:daily` or `button:confirm`.

## Methods

### get

```ts
get<Key>(key: Key): DispatchState[Key] | undefined
```

Read a key, `undefined` when nothing set it.

### require

```ts
require<Key>(
    key: Key
): Exclude<DispatchState[Key], undefined>
```

Read a key that must be present, with `undefined` stripped from the result.

### set

```ts
set<Key>(key: Key, value: DispatchState[Key]): void
```

Write a key for the rest of this dispatch to read.
