Edit

Share via


EventHandler class

Constructors

EventHandler(Logger)

Methods

addEventCallback(EventCallbackFunction, EventType[], string)

Adds event callbacks to array

emitEvent(EventType, InteractionType, EventPayload, EventError)

Emits events by calling callback with event message

removeEventCallback(string)

Removes callback with provided id from callback array

subscribeCrossTab()

Listen for events broadcasted from other tabs/instances

unsubscribeCrossTab()

Unsubscribe from broadcast events

Constructor Details

EventHandler(Logger)

new EventHandler(logger?: Logger)

Parameters

logger
Logger

Method Details

addEventCallback(EventCallbackFunction, EventType[], string)

Adds event callbacks to array

function addEventCallback(callback: EventCallbackFunction, eventTypes?: EventType[], callbackId?: string): null | string

Parameters

callback
EventCallbackFunction

callback to be invoked when an event is raised

eventTypes

EventType[]

list of events that this callback will be invoked for, if not provided callback will be invoked for all events

callbackId

string

Identifier for the callback, used to locate and remove the callback when no longer required

Returns

null | string

emitEvent(EventType, InteractionType, EventPayload, EventError)

Emits events by calling callback with event message

function emitEvent(eventType: EventType, interactionType?: InteractionType, payload?: EventPayload, error?: EventError)

Parameters

eventType

EventType

interactionType
InteractionType
payload
EventPayload
error
EventError

removeEventCallback(string)

Removes callback with provided id from callback array

function removeEventCallback(callbackId: string)

Parameters

callbackId

string

subscribeCrossTab()

Listen for events broadcasted from other tabs/instances

function subscribeCrossTab()

unsubscribeCrossTab()

Unsubscribe from broadcast events

function unsubscribeCrossTab()