Documentation
    Preparing search index...

    Interface EventDispatcher<T>

    Interface for an event dispatcher that sends events.

    interface EventDispatcher<T extends { type: string }> {
        addEventListener<
            P extends `ton-connect-${string}`
            | `ton-connect-ui-${string}`,
        >(
            eventName: P,
            listener: (
                event: CustomEvent<T & { type: RemoveTonConnectPrefix<P> }>,
            ) => void,
            options?: AddEventListenerOptions,
        ): Promise<() => void>;
        dispatchEvent<
            P extends `ton-connect-${string}`
            | `ton-connect-ui-${string}`,
        >(
            eventName: P,
            eventDetails: T & { type: RemoveTonConnectPrefix<P> },
        ): Promise<void>;
    }

    Type Parameters

    • T extends { type: string }

    Implemented by

    Index

    Methods

    • Adds an event listener.

      Type Parameters

      • P extends `ton-connect-${string}` | `ton-connect-ui-${string}`

      Parameters

      • eventName: P

        The name of the event to listen for.

      • listener: (event: CustomEvent<T & { type: RemoveTonConnectPrefix<P> }>) => void

        The listener to add.

      • Optionaloptions: AddEventListenerOptions

        The options for the listener.

      Returns Promise<() => void>

      A function that removes the listener.

    • Dispatches an event with the given name and details.

      Type Parameters

      • P extends `ton-connect-${string}` | `ton-connect-ui-${string}`

      Parameters

      • eventName: P

        The name of the event to dispatch.

      • eventDetails: T & { type: RemoveTonConnectPrefix<P> }

        The details of the event to dispatch.

      Returns Promise<void>