Skip to main content

projection

@rotorsoft/act-root


@rotorsoft/act-root / act/src / projection

Function: projection()

Call Signature

projection<TEvents>(target, events?): ProjectionBuilder<TEvents, string>

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

Creates a new projection builder with a static target stream.

All handlers inherit the target resolver automatically. Enables .batch() for bulk event processing in a single transaction.

Type Parameters

TEvents

TEvents extends Schemas = { }

Parameters

target

string

Static target stream for all handlers

events?

EventRegister<TEvents>

Returns

ProjectionBuilder<TEvents, string>

Call Signature

projection<TEvents>(target?, events?): object

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

Creates a new projection builder without a default target.

Use per-handler .to() / .void() to route events.

Type Parameters

TEvents

TEvents extends Schemas = { }

Parameters

target?

undefined

events?

EventRegister<TEvents>

Returns

build

build: () => Projection<TEvents>

Builds and returns the Projection data structure.

Returns

Projection<TEvents>

events

readonly events: EventRegister<TEvents>

The registered event schemas and their reaction maps.

on

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

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, undefined>

Parameters
handler

(event, stream) => Promise<void>

Returns

DoResult<TEvents, TKey, TData, undefined>