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

Event.ts overview

Since v1.0.0


Exports Grouped by Category


constructors

make

Signature

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>

Source

Since v1.0.0

guards

isEvent

Signature

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

Source

Since 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
}

Source

Since v1.0.0

Event (namespace)

Source

Since v1.0.0

Any (interface)

Signature

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

Source

Since v1.0.0

AnyWithProps (interface)

Signature

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

Source

Since v1.0.0

ToService (type alias)

Signature

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

Source

Since v1.0.0

Tag (type alias)

Signature

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

Source

Since v1.0.0

ErrorSchema (type alias)

Signature

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

Source

Since v1.0.0

Error (type alias)

Signature

type Schema.Schema.Type<ErrorSchema<A>> = Schema.Schema.Type<ErrorSchema<A>>

Source

Since v1.0.0

AddError (type alias)

Signature

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

Source

Since v1.0.0

PayloadSchema (type alias)

Signature

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

Source

Since v1.0.0

Payload (type alias)

Signature

type Schema.Schema.Type<PayloadSchema<A>> = Schema.Schema.Type<PayloadSchema<A>>

Source

Since v1.0.0

TaggedPayload (type alias)

Signature

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

Source

Since v1.0.0

SuccessSchema (type alias)

Signature

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

Source

Since v1.0.0

Success (type alias)

Signature

type Schema.Schema.Type<SuccessSchema<A>> = Schema.Schema.Type<SuccessSchema<A>>

Source

Since v1.0.0

Context (type alias)

Signature

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

Source

Since v1.0.0

WithTag (type alias)

Signature

type WithTag<Events, Tag> = Extract<Events, { readonly tag: Tag }>

Source

Since v1.0.0

ExcludeTag (type alias)

Signature

type ExcludeTag<Events, Tag> = Exclude<Events, { readonly tag: Tag }>

Source

Since v1.0.0

PayloadWithTag (type alias)

Signature

type Schema.Schema.Type<PayloadSchema<A>> = Payload<WithTag<Events, Tag>>

Source

Since v1.0.0

SuccessWithTag (type alias)

Signature

type Schema.Schema.Type<SuccessSchema<A>> = Success<WithTag<Events, Tag>>

Source

Since v1.0.0

ErrorWithTag (type alias)

Signature

type Schema.Schema.Type<ErrorSchema<A>> = Error<WithTag<Events, Tag>>

Source

Since v1.0.0

ContextWithTag (type alias)

Signature

type ContextWithTag<Events, Tag> = Context<WithTag<Events, Tag>>

Source

Since v1.0.0

EventHandler (interface)

Signature

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

Source

Since v1.0.0

type ids

TypeId

Signature

declare const TypeId: unique symbol

Source

Since v1.0.0

TypeId (type alias)

Signature

type TypeId = typeof TypeId

Source

Since v1.0.0