@eoussama/firemitt
    Preparing search index...

    Class EventHelper

    Helper class for managing custom events across different windows or iframes.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Initializes 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.

      Parameters

      • target: Window

        The target window to which messages will be sent.

      Returns boolean

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

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

      Type Parameters

      • T = unknown

        The expected type of data in the event message.

      Parameters

      • type: EventType

        The type of event to listen for.

      • func: (data?: T) => void

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

      Returns typeof EventHelper

      Returns the EventHelper class for method chaining.

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

      Type Parameters

      • T extends object = object

        The type of data being sent.

      Parameters

      • type: EventType

        The type of event.

      • Optionaldata: T

        Optional data to be included in the event message.

      Returns typeof EventHelper

      Returns the EventHelper class for method chaining.