ReadonlynameReadonlyhookSubscribe to meta changes. Provided by Bus after lifecycle setup.
Handle multiple events with the same handler.
EventSink receives raised event as first argument, payload as second argument.
Duplicate any with the same event set (order-independent) and handler honors
Options.duplicateSubscriptionStrategy.
Observe every raised event as a correlated {event, payload} message.
Does not create a graph edge. Unsubscribe via the returned Subscription.
Attach a graph edge to another Bus, or return a FilteredPipeHandle when given a PipePredicate for gated multi-hop relay.
pipe(dest) — first-hop / local raises always deliver to dest.pipe(predicate).pipe(dest) — stores predicate on the edge; passthrough (upstream-sourced)
events are delivered only when predicate returns true. Unfiltered outbound edges from
a bus that already has inbound pipes warn once per unique unsound path and block passthrough.Requires a real Bus instance — not a hand-rolled surface duck type.
Stop piping events into a bus previously passed to Bus.pipe.
Utility for resolving/rejecting a promise based on the reception of an event.
Promise resolves with the triggering event and its payload as {event, payload}.
Triggers must be SubscribableListenable values.
The '*' wildcard is not accepted (see SubscriptionSurface.next).
specific event(s) that reject the promise. Must be mutually disjoint with resolutionTrigger
// resolve on the first of several events
const {event, payload} = await bus.next(['message', 'connected', 'count']);
// conditional or filtered resolution — use scan (supports trigger: '*')
const ready = await bus.scan('*', (resolve) => {
if (resolve.trigger.type === 'event' && isReady(resolve.trigger)) {
resolve(true);
}
});
Utility for resolving/rejecting a promise based on an evaluation done when an event is triggered.
If options.eager is true (default), evaluates the condition immediately.
If the evaluator resolves or rejects during eager evaluation, the scanner does not subscribe to any events.
Listenable event or events that trigger the evaluator, including '*'.
Discriminate on resolve.trigger when reading event or payload.
attempt to pool scanners that share the same evaluator and trigger; default true.
StaticdefaultStaticdefaultStaticverboseStaticdefaultThe active state of the bus, i.e. does it have any subscribers. Subscribers include downstreams and scanners.
StaticconfigureMerge options onto Bus static defaults for all subsequently constructed
instances. Nested thresholds are merged recursively. name cannot be set here;
pass it to the constructor for per-instance naming.
Emit a void event with no payload (or an explicit null/undefined).
Optionalpayload: nullEmit an event with its correlated payload. The payload is required for any
event whose mapped type is not void; correlating it directly (rather than
through a rest tuple) lets it type-check even when TEventMap is a generic
type parameter, or when forwarding by a generic key over a concrete map
(T extends keyof M).
Correlated-tuple form: the (event, payload) pair must be one of the
[event, payload] tuples of TEventMap. Use this after discriminating on
event when both values started as independent unions.
Subscribe a callback to an event. Duplicate behavior is governed by Options.duplicateSubscriptionStrategy.
Optionaloptions: SubscribeOptionsRemove a handler previously registered with Bus.on.
Pass the same function reference; no-op if that handler is not registered for event.
Honors duplicateSubscriptionStrategy.disposal (collapse clears all stacked on intent;
stack pops the oldest frame — head of the stack). Does not remove Bus.once /
Bus.any / Bus.tap intent.
Subscribe a callback to an event. Automatically unsubscribes after the first invocation.
Duplicate once registrations honor strategy observability, invocation, and logLevel;
disposal is always isolated from Bus.on for the same handler.
Optionaloptions: SubscribeOptionsSubscribe to meta states of the Bus, idle and active.
Bus becomes idle when it goes from 1 to 0 subscribers, and active when it goes from 0 to 1.
The handler receives a boolean indicating if the bus is active (true) or idle (false)
Whether the bus has any listeners in options.scope (defaults to ListenerScope.ANY).
Total handler registrations in options.scope (defaults to ListenerScope.ANY).
For ListenerScope.ANY, sums own and downstream counts (the same handler on both
still counts twice).
Remove all event subscribers, lifecycle subscribers, and downstreams. Triggers lifecycle meta events for all subscribed events before removing lifecycle subscribers, emitting Lifecycle.willDestroy during teardown.
Emit events and tear down a Bus instance.
Extends EmittingSurface with ControlSurface.destroy. Prefer EmittingSurface when a dependency may raise events but must not destroy the bus.
Event-map typing is bivariant (no
in out) so a surface over a wider map is assignable to a narrower view — the same Wide→Narrow shape as Bus.