Skip to main content

Interface: useEventBusType




fire: (eventTarget: EventTarget, eventName: string, data?: any, options?: EventBusOptions) => EventBus

Type declaration

▸ (eventTarget, eventName, data?, options?): EventBus

Fires a new custom event of the specified name, carrying the provided data.

Note that this method does not prevent the event listeners to modify the data in any way. The order in which the event listeners will be executed is unspecified and should not be relied upon.

Note that the default options are { bubbles: true, cancelable: true }, which is different from the default values used in the native custom events ({ bubbles: false, cancelable: false }).

eventTargetEventTargetThe event target at which the event will be dispatched (e.g. element/document/window).
eventNamestringThe name of the event to fire.
data?anyThe data to pass to the event listeners.
options?EventBusOptionsThe override of the default options passed to the constructor of the custom event fired by this event bus. The default options passed to the custom event constructor are { bubbles: true, cancelable: true }.


This custom event bus.


Thrown if the provided event target cannot be used to fire the event.


Defined in