Constructor
new TypedEventBus(optionsopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options | object | <optional> |
- Source
Classes
Methods
clear(eventTypeopt)
Clears listeners for a given event type or all listeners if omitted.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType | string | | <optional> |
- Source
emit(eventType, dataopt) → {Object}
Emits an event with prioritized dispatch, recursion bounding, self-removal safety, and stopPropagation support.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
eventType | string | | |||
data | any | <optional> | {} |
- Source
Returns:
- Type:
- Object
hasListeners(eventType) → {boolean}
Checks if there are any active listeners for an event type.
Parameters:
| Name | Type | Description |
|---|---|---|
eventType | string | |
- Source
Returns:
- Type:
- boolean
listenerCount(eventTypeopt) → {number}
Returns the count of active listeners for an event type (or all events).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType | string | | <optional> |
- Source
Returns:
- Type:
- number
off(eventType, listenerOrId) → {boolean}
Unsubscribes a listener by function reference or registration ID.
Parameters:
| Name | Type | Description |
|---|---|---|
eventType | string | | |
listenerOrId | function | |
- Source
Returns:
- Type:
- boolean
on(eventType, listener, optionsopt) → {function}
Subscribes a prioritized listener to an event type.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType | string | | ||
listener | function | ||
options | number | | <optional> |
- Source
Returns:
Idempotent unbind function
- Type:
- function
once(eventType, listener, optionsopt) → {function}
Subscribes a listener that runs at most once.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType | string | | ||
listener | function | ||
options | number | | <optional> |
- Source
Returns:
- Type:
- function