Skip to content

Why an event was recorded. Every event carries two ids:

  • correlationId is shared by everything that follows from one original request, across aggregates and view models.
  • causationId names what directly caused the command that recorded it: the request, or the event a view model or saga was reacting to.

They travel in the fiber’s context rather than in payloads. A command run outside any causation starts a new correlation with a fresh id. Inside a view model handler the event being handled is the cause, so a chain of reactions can be drawn as a tree without passing ids around by hand.

Defined in: src/Causation.ts:19

readonly causationId: string

Defined in: src/Causation.ts:21

readonly correlationId: string

Defined in: src/Causation.ts:20

const CurrentCausation: Reference<Causation | undefined>

Defined in: src/Causation.ts:25

The causation of commands run in this fiber, undefined outside any.


const withCausation: {(causation): <A, E, R>(effect) => Effect<A, E, R>; <A, E, R>(effect, causation): Effect<A, E, R>; }

Defined in: src/Causation.ts:30

Runs an effect with this causation, for instance the id of an incoming HTTP request.

(causation): <A, E, R>(effect) => Effect<A, E, R>

Causation

<A, E, R>(effect) => Effect<A, E, R>

<A, E, R>(effect, causation): Effect<A, E, R>

A

E

R

Effect<A, E, R>

Causation

Effect<A, E, R>

causedBy(event): <A, E, R>(effect) => Effect<A, E, R>

Defined in: src/Causation.ts:49

Runs an effect in reaction to a stored event, so commands it runs record that event as their cause. View models do this for their handlers already.

string = Schema.String

string = Schema.String

string | null = ...

What directly caused the command that recorded the event: a request, a command or another event.

string | null = ...

Shared by everything that follows from one original request.

{[key: string]: Json; } = Schema.JsonObject

What the command carried beside its payload, see Metadata. Events from before metadata existed have {}.

Json = Schema.Json

number = Schema.Int

number = Schema.Int

The version of the event’s schema the payload was written with. Events from before versions existed are 1.

Utc = Schema.DateTimeUtcFromMillis

string = Schema.String

number = Schema.Int

<A, E, R>(effect) => Effect<A, E, R>


fromEvent(event): Causation

Defined in: src/Causation.ts:40

The causation of commands run in reaction to a stored event.

string = Schema.String

string = Schema.String

string | null = ...

What directly caused the command that recorded the event: a request, a command or another event.

string | null = ...

Shared by everything that follows from one original request.

{[key: string]: Json; } = Schema.JsonObject

What the command carried beside its payload, see Metadata. Events from before metadata existed have {}.

Json = Schema.Json

number = Schema.Int

number = Schema.Int

The version of the event’s schema the payload was written with. Events from before versions existed are 1.

Utc = Schema.DateTimeUtcFromMillis

string = Schema.String

number = Schema.Int

Causation