AutoclosePredicate
@rotorsoft/act-root / act/src / AutoclosePredicate
Type Alias: AutoclosePredicate<TEvents>
AutoclosePredicate<
TEvents> = (stream,head,count) =>boolean
Defined in: libs/act/src/types/action.ts:579
Predicate consulted by the online close cycle once per candidate
stream of a state with .autocloses(...) declared. Returning true
schedules the stream for atomic truncate-and-seed via
Store.truncate on the next batch.
The head argument is the latest committed (non-tombstone) event on
the stream; predicates that gate on the last event name (the same
shape .autocloses({ is: "EventName" }) compiles to) read head.name
directly and the type system autocompletes it to the state's event
union. count is the stream's total event count.
Predicates run in process per cycle tick; they MUST be pure and fast โ slow predicates serialize behind the cycle's batch.
Type Parametersโ
TEventsโ
TEvents extends Schemas
Event schemas declared by the owning state via
.emits({...}). head.event.name autocompletes to
keyof TEvents.
Parametersโ
streamโ
string
headโ
Committed<TEvents, keyof TEvents>
countโ
number
Returnsโ
boolean