StaticdisposeRemoves all active message listeners registered by this helper. Called before each new session to prevent stale handlers from a previous session from intercepting events meant for the new one.
StaticinitInitializes the EventHelper with a target window.
This method sets the target window where the messages will be posted to. Any listeners registered during a previous session are removed first. The calling page's window is captured as the host window for message listeners. When no target is given, nothing is changed and the current session is left untouched.
The target window to which messages will be sent.
Returns true if the target is successfully set, otherwise false.
StaticonSets up a one-time event listener for a specific event type.
This method listens for messages of the specified event type and executes the provided function the first time such an event occurs.
Untrusted events, events that are not valid encoded messages, and (when options.source is not undefined) events
coming from any other source are ignored.
The expected type of data in the event message.
The type of event to listen for.
The function to execute when the event is received. It receives the event data and the raw message event.
Optionaloptions: TListenOptions = {}
Optional listener options.
Returns the EventHelper class for method chaining.
StaticsendSends a message to the target window.
This method encodes a message of the specified event type and data, then posts it to the target window. It does nothing when EventHelper.init was never called successfully.
The type of data being sent.
Returns the EventHelper class for method chaining.
Helper class for managing custom events across different windows or iframes.
This class provides static methods to initialize the event system, send encoded messages, and listen for specific event types. It uses the
Base64helperclass for encoding and decoding messages.