# DispatchContext

`class` in `core` · v0.7.0

<https://docs.seedcord.org/packages/core/0.7.0/classes/dispatch-context>

A typed bag allocated once per interaction dispatch and handed to the handler. The middleware and i18n work reads and writes it through DispatchState. Today the bag is empty, so it only carries the dispatched `routeId`.

```ts
class DispatchContext implements DispatchBag
```

## Constructors

### constructor

```ts
DispatchContext(routeId: string)
```

Constructs a new instance of the `DispatchContext` class

## Properties

### id

```ts
public readonly id: `${string}-${string}-${string}-${string}-${string}`
```

### routeId

```ts
public readonly routeId: string
```

## Methods

### get

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

### require

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

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

### set

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