TypedEventBus

Prioritized event dispatcher handling self-removing listeners, bounded recursive events, duplicate guards, once-only subscriptions, and clean unbind.

Constructor

new TypedEventBus(optionsopt)

Parameters:
NameTypeAttributesDescription
optionsobject<optional>

Classes

TypedEventBus

Methods

clear(eventTypeopt)

Clears listeners for a given event type or all listeners if omitted.

Parameters:
NameTypeAttributesDescription
eventTypestring | symbol<optional>

emit(eventType, dataopt) → {Object}

Emits an event with prioritized dispatch, recursion bounding, self-removal safety, and stopPropagation support.

Parameters:
NameTypeAttributesDefaultDescription
eventTypestring | symbol
dataany<optional>
{}
Returns:
Type: 
Object

hasListeners(eventType) → {boolean}

Checks if there are any active listeners for an event type.

Parameters:
NameTypeDescription
eventTypestring | symbol
Returns:
Type: 
boolean

listenerCount(eventTypeopt) → {number}

Returns the count of active listeners for an event type (or all events).

Parameters:
NameTypeAttributesDescription
eventTypestring | symbol<optional>
Returns:
Type: 
number

off(eventType, listenerOrId) → {boolean}

Unsubscribes a listener by function reference or registration ID.

Parameters:
NameTypeDescription
eventTypestring | symbol
listenerOrIdfunction | string
Returns:
Type: 
boolean

on(eventType, listener, optionsopt) → {function}

Subscribes a prioritized listener to an event type.

Parameters:
NameTypeAttributesDescription
eventTypestring | symbol
listenerfunction
optionsnumber | object<optional>
Returns:

Idempotent unbind function

Type: 
function

once(eventType, listener, optionsopt) → {function}

Subscribes a listener that runs at most once.

Parameters:
NameTypeAttributesDescription
eventTypestring | symbol
listenerfunction
optionsnumber | object<optional>
Returns:
Type: 
function