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

Event overview

Added in v1.0.0


Table of contents


constructors

make

Signature

export declare const make: <
  Tag extends string,
  Payload extends Schema.Schema.Any = any,
  Success extends Schema.Schema.Any = any,
  Error extends Schema.Schema.All = any
>(options: {
  readonly tag: Tag
  readonly primaryKey: (payload: Schema.Schema.Type<Payload>) => string
  readonly payload?: Payload
  readonly success?: Success
  readonly error?: Error
}) => Event<Tag, Payload, Success, Error>

Added in v1.0.0

guards

isEvent

Signature

export declare const isEvent: (u: unknown) => u is Event<any, any, any, any>

Added in v1.0.0

models

Event (interface)

Represents an event in an EventLog.

Signature

export interface Event<
  out Tag extends string,
  in out Payload extends Schema.Schema.Any = typeof Schema.Void,
  in out Success extends Schema.Schema.Any = typeof Schema.Void,
  in out Error extends Schema.Schema.All = typeof Schema.Never
> {
  readonly [TypeId]: TypeId
  readonly tag: Tag
  readonly primaryKey: (payload: Schema.Schema.Type<Payload>) => string
  readonly payload: Payload
  readonly payloadMsgPack: MsgPack.schema<Payload>
  readonly success: Success
  readonly error: Error
}

Added in v1.0.0

Event (namespace)

Added in v1.0.0

Any (interface)

Signature

export interface Any {
  readonly [TypeId]: TypeId
  readonly tag: string
}

Added in v1.0.0

AnyWithProps (interface)

Signature

export interface AnyWithProps extends Event<string, Schema.Schema.Any, Schema.Schema.Any, Schema.Schema.Any> {}

Added in v1.0.0

AddError (type alias)

Signature

export type AddError<A extends Any, Error extends Schema.Schema.Any> =
  A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error>
    ? Event<_Tag, _Payload, _Success, _Error | Error>
    : never

Added in v1.0.0

Context (type alias)

Signature

export type Context<A> =
  A extends Event<infer _Name, infer _Payload, infer _Success, infer _Error>
    ? Schema.Schema.Context<_Payload> | Schema.Schema.Context<_Success> | Schema.Schema.Context<_Error>
    : never

Added in v1.0.0

ContextWithTag (type alias)

Signature

export type ContextWithTag<Events extends Any, Tag extends string> = Context<WithTag<Events, Tag>>

Added in v1.0.0

Error (type alias)

Signature

export type Error<A extends Any> = Schema.Schema.Type<ErrorSchema<A>>

Added in v1.0.0

ErrorSchema (type alias)

Signature

export type ErrorSchema<A extends Any> =
  A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Error : never

Added in v1.0.0

ErrorWithTag (type alias)

Signature

export type ErrorWithTag<Events extends Any, Tag extends string> = Error<WithTag<Events, Tag>>

Added in v1.0.0

ExcludeTag (type alias)

Signature

export type ExcludeTag<Events extends Any, Tag extends string> = Exclude<Events, { readonly tag: Tag }>

Added in v1.0.0

Payload (type alias)

Signature

export type Payload<A extends Any> = Schema.Schema.Type<PayloadSchema<A>>

Added in v1.0.0

PayloadSchema (type alias)

Signature

export type PayloadSchema<A extends Any> =
  A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Payload : never

Added in v1.0.0

PayloadWithTag (type alias)

Signature

export type PayloadWithTag<Events extends Any, Tag extends string> = Payload<WithTag<Events, Tag>>

Added in v1.0.0

Success (type alias)

Signature

export type Success<A extends Any> = Schema.Schema.Type<SuccessSchema<A>>

Added in v1.0.0

SuccessSchema (type alias)

Signature

export type SuccessSchema<A extends Any> =
  A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Success : never

Added in v1.0.0

SuccessWithTag (type alias)

Signature

export type SuccessWithTag<Events extends Any, Tag extends string> = Success<WithTag<Events, Tag>>

Added in v1.0.0

Tag (type alias)

Signature

export type Tag<A> = A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? _Tag : never

Added in v1.0.0

TaggedPayload (type alias)

Signature

export type TaggedPayload<A extends Any> =
  A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error>
    ? {
        readonly _tag: _Tag
        readonly payload: Schema.Schema.Type<_Payload>
      }
    : never

Added in v1.0.0

ToService (type alias)

Signature

export type ToService<A> =
  A extends Event<infer _Tag, infer _Payload, infer _Success, infer _Error> ? EventHandler<_Tag> : never

Added in v1.0.0

WithTag (type alias)

Signature

export type WithTag<Events extends Any, Tag extends string> = Extract<Events, { readonly tag: Tag }>

Added in v1.0.0

EventHandler (interface)

Signature

export interface EventHandler<in out Tag extends string> {
  readonly _: unique symbol
  readonly tag: Tag
}

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