Description

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 Base64helper class for encoding and decoding messages.

Constructors

Properties

Methods

Constructors

Properties

target: Window

Methods

  • Parameters

    • target: Window

      The target window to which messages will be sent.

    Returns boolean

    Returns true if the target is successfully set, otherwise false.

    Description

    Initializes the EventHelper with a target window.

    This method sets the target window where the messages will be posted to.

    Static

  • Type Parameters

    • T = any

      The expected type of data in the event message.

    Parameters

    • type: EventType

      The type of event to listen for.

    • func: ((data?) => any)

      The function to execute when the event is received. It receives the event data as an argument.

        • (data?): any
        • Parameters

          • Optional data: T

          Returns any

    Returns typeof EventHelper

    Returns the EventHelper class for method chaining.

    Description

    Sets up an event listener for a specific event type.

    This method listens for messages of the specified event type and executes the provided function when such an event occurs.

    Static

  • Type Parameters

    • T = any

      The type of data being sent.

    Parameters

    • type: EventType

      The type of event.

    • Optional data: T

      Optional data to be included in the event message.

    Returns typeof EventHelper

    Returns the EventHelper class for method chaining.

    Description

    Sends 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.

    Static

Generated using TypeDoc