Effect-based publish/subscribe event bus: per-instance PubSub channels (typed + wildcard) bridged to the process-wide GlobalBus, with Promise/callback helpers for non-Effect callers.

Classes

Service

Members

(static, constant) InstanceDisposed

Event published right before an instance's bus is shut down, carrying the instance directory.

(static, constant) defaultLayer

Default layer used when no explicit Bus layer is provided.

(static, constant) layer

Effect layer that builds the Bus service: per-instance state plus publish/subscribe operations.

Methods

(static) createID() → {string}

Generate a new ascending event id.

Returns:

A fresh "evt" identifier.

Type: 
string

(static) publish(def, properties, options) → {Promise.<void>}

Publish an event from non-Effect code (resolves once published).

Parameters:
NameTypeDescription
defObject

Event definition identifying the channel/type.

propertiesObject

Event payload properties.

optionsObject

Optional overrides; id sets an explicit event id.

Returns:

Resolves when the event has been published.

Type: 
Promise.<void>

(static) subscribe(def, callback) → {function}

Subscribe to a single event type with a callback from non-Effect code.

Parameters:
NameTypeDescription
defObject

Event definition identifying the typed channel.

callbackfunction

Invoked with each payload of def.type.

Returns:

Unsubscribe function.

Type: 
function

(static) subscribeAll(callback) → {function}

Subscribe to all event types with a callback from non-Effect code.

Parameters:
NameTypeDescription
callbackfunction

Invoked with each published payload.

Returns:

Unsubscribe function.

Type: 
function