Skip to content

EventGroup

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.

11 exports Added in v4.0.0 Source

Constructors

empty

Added in v4.0.0 Source

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>;

Guards

isEventGroup

Added in v4.0.0 Source

Returns true when a value is an event log event group.

Signature

declare function isEventGroup(u: unknown): u is Any;

Models

Any interface

Added in v4.0.0 Source

Type-erased marker for an event log event group.

Signature

interface Any {
  readonly "~effect/eventlog/EventGroup": "~effect/eventlog/EventGroup";
}

AnyWithProps type

Added in v4.0.0 Source

Type-erased event group with its events record available structurally.

Signature

type AnyWithProps = EventGroup<Event.Any>;

EventGroup interface

Added in v4.0.0 Source

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

interface EventGroup<out Events extends Event.Any = Event.Any> extends Pipeable {
  readonly "~effect/eventlog/EventGroup": "~effect/eventlog/EventGroup";
  readonly events: Record.ReadonlyRecord<string, Events>;
  add<
    Tag extends string,
    Payload extends Top = Void,
    Success extends Top = Void,
    Error extends Top = Never,
  >(options: {
    readonly error?: Error;
    readonly payload?: Payload;
    readonly primaryKey: (payload: Type<Payload>) => string;
    readonly success?: Success;
    readonly tag: Tag;
  }): EventGroup<Events | Event<Tag, Payload, Success, Error>>;
  addError<Error extends Top>(error: Error): EventGroup<AddError<Events, Error>>;
}

Type IDs

TypeId

Added in v4.0.0 Source

Runtime type identifier used to mark event log event groups.

Signature

declare const TypeId: "~effect/eventlog/EventGroup";

TypeId type

Added in v4.0.0 Source

Unique type identifier used to mark event log event groups.

Signature

type TypeId = "~effect/eventlog/EventGroup";

Utility Types

Events type

Added in v4.0.0 Source

Extracts the union of event definitions contained in an event group.

Signature

type Events<Group> = Group extends EventGroup<infer _Events> ? _Events : never;

ServicesClient type

Added in v4.0.0 Source

Client-side schema services required by all events in an event group.

Signature

type ServicesClient<Group> = Event.ServicesClient<Events<Group>>;

ServicesServer type

Added in v4.0.0 Source

Server-side schema services required by all events in an event group.

Signature

type ServicesServer<Group> = Event.ServicesServer<Events<Group>>;

ToService type

Added in v4.0.0 Source

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> : never;