html2app • JS Bridge
    Preparing search index...

    Variable communicationConst

    communication: {
        get isReady(): boolean;
        get isWebView(): boolean;
        init(): void;
        sendAsync<T extends Record<string, any>>(
            message: Message,
        ): Promise<MessageResponse<T>>;
        sendVoid(message: Message): void;
        on(event: string, listener: (...args: any[]) => void): void;
        off(event: string, listener: (...args: any[]) => void): void;
        offMany(events: string): void;
        destroy(): void;
    } = ...

    Shared communication module for Flutter WebView bridge.

    Type Declaration

    • get isReady(): boolean

      Whether the bridge is initialized and ready

    • get isWebView(): boolean

      Whether running inside Flutter WebView

    • init: function
      • Initialize or reinitialize the communication bridge. Automatically called on first import if running in Flutter WebView. Call this manually after destroy() to reactivate the bridge.

        Returns void

    • sendAsync: function
      • Send an async message to Flutter and wait for response.

        Type Parameters

        • T extends Record<string, any>

        Parameters

        • message: Message

          The message to send

        Returns Promise<MessageResponse<T>>

        Promise resolving to the response

    • sendVoid: function
      • Send a fire-and-forget message to Flutter.

        Parameters

        • message: Message

          The message to send

        Returns void

    • on: function
      • Add an event listener for a specific event/action from Flutter.

        Parameters

        • event: string

          The event name to listen for

        • listener: (...args: any[]) => void

          The callback function

        Returns void

    • off: function
      • Remove a specific event listener.

        Parameters

        • event: string

          The event name

        • listener: (...args: any[]) => void

          The callback function to remove

        Returns void

    • offMany: function
      • Remove all event listeners for specific event(s).

        Parameters

        • events: string

          Comma-separated list of event names

        Returns void

    • destroy: function
      • Clean up all resources to prevent memory leaks. Call this when the bridge is no longer needed.

        Returns void

    This module manages the message bridge between the web page and Flutter app. It handles callbacks for async messages and event listeners for action notifications. Only one message listener is created regardless of how many plugins are used.