Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

Event

7 exports Since v1.0.0 Source

Constructors

Since v1.0.0

Signature

declare function make<Tag extends string, Payload extends Any = Void, Success extends Any = Void, Error extends All = Never>(options: {
readonly error?: Error;
readonly payload?: Payload;
readonly primaryKey: (payload: Type<Payload>) => string;
readonly success?: Success;
readonly tag: Tag;
}): Event<Tag, Payload, Success, Error>

Guards

Since v1.0.0

Signature

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

Models

Since v1.0.0

Event

interface
Since v1.0.0

Represents an event in an EventLog.

Signature

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]: typeof TypeId;
readonly error: Error;
readonly payload: Payload;
readonly payloadMsgPack: schema<Payload>;
readonly primaryKey: (payload: Type<Payload>) => string;
readonly success: Success;
readonly tag: Tag;
}

EventHandler

interface
Since v1.0.0

Signature

interface EventHandler<in out Tag extends string> {
readonly _: typeof _;
readonly tag: Tag;
}

Type Ids

Since v1.0.0

Signature

declare const TypeId: unique symbol
Since v1.0.0

Signature

type TypeId = typeof TypeId