Skip to main content

StateBuilder

@rotorsoft/act-root


@rotorsoft/act-root / act/src / StateBuilder

Type Alias: StateBuilder<S>

StateBuilder<S> = object

Defined in: libs/act/src/state-builder.ts:22

Type Parameters

S

S extends Schema

Properties

init()

init: (init) => object

Defined in: libs/act/src/state-builder.ts:28

Define the initial state for the state machine.

Parameters

init

() => Readonly<S>

Function returning the initial state

Returns

An object with .emits() to declare event types

emits()

emits: <E>(events) => object

Declare the event types the state machine can emit.

Type Parameters
E

E extends Schemas

Parameters
events

ZodTypes<E>

Zod schemas for each event

Returns

An object with .patch() to define event handlers

patch()

patch: (patch) => ActionBuilder<S, E, { }>

Define how each event updates state.

Parameters
patch

PatchHandlers<S, E>

Event handler functions

Returns

ActionBuilder<S, E, { }>

An ActionBuilder for defining actions