Skip to main content

ProjectionBuilder

@rotorsoft/act-root


@rotorsoft/act-root / act/src / ProjectionBuilder

Type Alias: ProjectionBuilder<TEvents>

ProjectionBuilder<TEvents> = object

Defined in: libs/act/src/projection-builder.ts:64

Fluent builder interface for composing projections.

Provides a chainable API for registering event handlers that update read models. Unlike slices, projections have no .withState() for states and handlers do not receive a Dispatcher.

When a default target is provided via projection("target"), all handlers inherit that resolver. Per-handler .to() or .void() can still override it.

Type Parameters

TEvents

TEvents extends Schemas

Event schemas

Properties

build()

build: () => Projection<TEvents>

Defined in: libs/act/src/projection-builder.ts:85

Builds and returns the Projection data structure.

Returns

Projection<TEvents>


events

readonly events: EventRegister<TEvents>

Defined in: libs/act/src/projection-builder.ts:89

The registered event schemas and their reaction maps.


on()

on: <TKey, TData>(entry) => object

Defined in: libs/act/src/projection-builder.ts:72

Begins defining a projection handler for a specific event.

Pass a { EventName: schema } record — use shorthand { EventName } when the variable name matches the event name. The key becomes the event name, the value the Zod schema.

Type Parameters

TKey

TKey extends string

TData

TData extends Schema

Parameters

entry

EventEntry<TKey, TData>

Returns

object

do()

do: (handler) => DoResult<TEvents, TKey, TData>

Parameters
handler

(event, stream) => Promise<void>

Returns

DoResult<TEvents, TKey, TData>