Skip to content

EventBus

EventBus<S> = object

Defined in: Core/EventBus.ts:38

An event bus pipeline for a typed message schema S.

EventBus provides typed event emission, sequence matching, state reduction, and structural event bus forwarding with zero-overhead reentrant queuing.

type AppMessages = {
  userLoggedIn: { userId: string };
  checkoutStarted: { amount: number };
};

const appBus = EventBus.make<AppMessages>();

const subscription = EventBus.subscribe(
  appBus,
  ["userLoggedIn", "checkoutStarted"],
  { ordered: true }
).collect((payloads) => {
  console.log("Checkout started for:", payloads.userLoggedIn.userId);
});

EventBus.emit(appBus, {
  kind: "userLoggedIn",
  value: { userId: "user-1" },
});

S extends Record<string, unknown>

readonly [_eventBusBrand]: (schema) => S

Defined in: Core/EventBus.ts:41

S

S


readonly optional [toStringTag]?: string

Defined in: Core/EventBus.ts:40


readonly optional id?: string

Defined in: Core/EventBus.ts:39