Skip to content
Interfacetypesv0.14.4

DispatchBag

The read and write surface of the per-dispatch bag. DispatchContext in @seedcord/core implements it. Declared here so RenderContext can carry one without importing the concrete class.

interface DispatchBag

id

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.

readonly id: string

routeId

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

readonly routeId: string

require()

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

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

Throws:

A SeedcordError If nothing set the key on this dispatch.

set()

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

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