EventGroup.ts
EventGroup.ts overview
Section titled “EventGroup.ts overview”Defines groups of typed events for the unstable event-log system.
An EventGroup collects event definitions that belong together. Start with
empty, add events with their payload, success, and error schemas, then use
the group to build clients with EventLog.schema and server handlers with
EventLog.group. The group only describes events; it does not write or run
them.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”Creates an empty event group used as the starting point for defining a group.
When to use
Use when you need the starting EventGroup value before adding event
definitions with .add(...).
Signature
declare const empty: EventGroup<never>Since v4.0.0
guards
Section titled “guards”isEventGroup
Section titled “isEventGroup”Returns true when a value is an event log event group.
Signature
declare const isEventGroup: (u: unknown) => u is AnySince v4.0.0
models
Section titled “models”Any (interface)
Section titled “Any (interface)”Type-erased marker for an event log event group.
Signature
export interface Any { readonly [TypeId]: TypeId}Since v4.0.0
AnyWithProps (type alias)
Section titled “AnyWithProps (type alias)”Type-erased event group with its events record available structurally.
Signature
type AnyWithProps = EventGroup<Event.Any>Since v4.0.0
EventGroup (interface)
Section titled “EventGroup (interface)”Typed collection of event definitions that represents a portion of an event log domain.
When to use
Use when build groups from empty.add(...), then provide implementations for the events
with EventLog.group.
Signature
export interface EventGroup<out Events extends Event.Any = Event.Any> extends Pipeable { readonly [TypeId]: TypeId readonly events: Record.ReadonlyRecord<string, Events>
/** * Add an `Event` to the `EventGroup`. */ add< Tag extends string, Payload extends Schema.Top = typeof Schema.Void, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never >(options: { readonly tag: Tag readonly primaryKey: (payload: Schema.Schema.Type<Payload>) => string readonly payload?: Payload readonly success?: Success readonly error?: Error }): EventGroup<Events | Event.Event<Tag, Payload, Success, Error>>
/** * Add an error schema to all the events in the `EventGroup`. */ addError<Error extends Schema.Top>(error: Error): EventGroup<Event.AddError<Events, Error>>}Since v4.0.0
Events (type alias)
Section titled “Events (type alias)”Extracts the union of event definitions contained in an event group.
Signature
type Events<Group> = Group extends EventGroup<infer _Events> ? _Events : neverSince v4.0.0
ServicesClient (type alias)
Section titled “ServicesClient (type alias)”Client-side schema services required by all events in an event group.
Signature
type ServicesClient<Group> = Event.ServicesClient<Events<Group>>Since v4.0.0
ServicesServer (type alias)
Section titled “ServicesServer (type alias)”Server-side schema services required by all events in an event group.
Signature
type ServicesServer<Group> = Event.ServicesServer<Events<Group>>Since v4.0.0
ToService (type alias)
Section titled “ToService (type alias)”Derives the handler service markers required for all events in an event group.
Signature
type ToService<A> = A extends EventGroup<infer _Events> ? Event.ToService<_Events> : neverSince v4.0.0
type IDs
Section titled “type IDs”TypeId
Section titled “TypeId”Runtime type identifier used to mark event log event groups.
Signature
declare const TypeId: "~effect/eventlog/EventGroup"Since v4.0.0
TypeId (type alias)
Section titled “TypeId (type alias)”Unique type identifier used to mark event log event groups.
Signature
type TypeId = "~effect/eventlog/EventGroup"Since v4.0.0