Skip to main content Link Search Menu Expand Document (external link)

EventGroup overview

Added in v1.0.0


Table of contents


constructors

empty

An EventGroup is a collection of Events. You can use an EventGroup to represent a portion of your domain.

The events can be implemented later using the EventLog.group api.

Signature

export declare const empty: EventGroup<never>

Added in v1.0.0

guards

isEventGroup

Signature

export declare const isEventGroup: (u: unknown) => u is EventGroup.Any

Added in v1.0.0

models

EventGroup (interface)

An EventGroup is a collection of Events. You can use an EventGroup to represent a portion of your domain.

The events can be implemented later using the EventLogBuilder.group api.

Signature

export interface EventGroup<out Events extends Event.Any = never> extends Pipeable {
  new (_: never): {}

  readonly [TypeId]: TypeId
  readonly events: Record.ReadonlyRecord<string, Events>

  /**
   * Add an `Event` to the `EventGroup`.
   */
  add<
    Tag extends string,
    Payload extends Schema.Schema.Any = typeof Schema.Void,
    Success extends Schema.Schema.Any = typeof Schema.Void,
    Error extends Schema.Schema.All = 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<Tag, Payload, Success, Error>>

  /**
   * Add an error schema to all the events in the `EventGroup`.
   */
  addError<Error extends Schema.Schema.Any>(error: Error): EventGroup<Event.AddError<Events, Error>>
}

Added in v1.0.0

EventGroup (namespace)

Added in v1.0.0

Any (interface)

Signature

export interface Any {
  readonly [TypeId]: TypeId
}

Added in v1.0.0

AnyWithProps (type alias)

Signature

export type AnyWithProps = EventGroup<Event.AnyWithProps>

Added in v1.0.0

Context (type alias)

Signature

export type Context<Group> = Event.Context<Events<Group>>

Added in v1.0.0

Events (type alias)

Signature

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

Added in v1.0.0

ToService (type alias)

Signature

export type ToService<A> = A extends EventGroup<infer _Events> ? Event.ToService<_Events> : never

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0