GeoLeaf Core API - v3.0.0
    Preparing search index...

    Interface IEventBus<TMap>

    Formal typed interface for the GeoLeaf DOM event bus.

    The type parameter TMap maps event names to their detail payloads. Defaults to GeoLeafEventMap for the built-in bus.

    interface IEventBus<TMap = GeoLeafEventMap> {
        dispatch<K extends string | number | symbol>(
            name: K,
            detail: TMap[K],
        ): void;
        on<K extends string | number | symbol>(
            event: K,
            handler: (e: CustomEvent<TMap[K]>) => void,
        ): () => void;
        off<K extends string | number | symbol>(
            event: K,
            handler: (e: CustomEvent<TMap[K]>) => void,
        ): void;
    }

    Type Parameters

    Index

    Methods

    Methods

    • Dispatches a typed custom event on document.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • name: K

        Event name (key of TMap).

      • detail: TMap[K]

        Typed payload matching the event's entry in TMap.

      Returns void

    • Subscribes to a typed custom event.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • event: K

        Event name (key of TMap).

      • handler: (e: CustomEvent<TMap[K]>) => void

        Handler receiving a CustomEvent with the typed detail.

      Returns () => void

      Unsubscribe function.

    • Unsubscribes a previously registered handler.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • event: K

        Event name (key of TMap).

      • handler: (e: CustomEvent<TMap[K]>) => void

        The exact handler reference passed to on().

      Returns void