projection
@rotorsoft/act-root / act/src / projection
Function: projection()
Call Signature
projection<
TEvents>(target):ProjectionBuilder<TEvents,string>
Defined in: libs/act/src/builders/projection-builder.ts:263
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
Returns
ProjectionBuilder<TEvents, string>
Call Signature
projection<
TEvents>(target?):object
Defined in: libs/act/src/builders/projection-builder.ts:271
Creates a new projection builder without a default target.
Use per-handler .to() to route events to different streams.
Type Parameters
TEvents
TEvents extends Schemas = { }
Parameters
target?
undefined
Returns
build
build: () =>
Projection<TEvents>
Builds and returns the Projection data structure.
Returns
Projection<TEvents>
events
readonlyevents: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>