Skip to main content

Interface: useEventBusType

@ima/react-page-renderer.useEventBusType

Properties

fire

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 }).

Parameters
NameTypeDescription
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 }.
Returns

EventBus

This custom event bus.

Throws

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

See

https://developer.mozilla.org/en-US/docs/Web/API/Event/Event

Defined in

packages/react-page-renderer/src/hooks/eventBus.ts:7