TomTom Maps for JavaScript
    Preparing search index...

    Class CombinedEvents<T, CFG, TShown>

    Unified events interface that blends user interaction events and module lifecycle events under a single on / off surface.

    User event types (click, contextmenu, hover, long-hover) are handled by the underlying UserEvents instance and removed with off.

    Module lifecycle event types (config-change, shown-features) are handled by the underlying ModuleEvents instance. Each on call returns an unsubscribe function. Both user and module event types are also removable in bulk via off.

    // User interaction
    const unsub = places.events.on('click', (feature, lngLat) => {
    console.log('Clicked place:', feature.properties.name);
    });

    // Module lifecycle
    const unsubConfig = places.events.on('config-change', (config) => {
    console.log('Config updated:', config);
    });

    const unsubShown = places.events.on('shown-features', (features) => {
    console.log('Shown:', features);
    });

    // Cleanup
    unsub();
    unsubConfig();
    unsubShown();
    places.events.off('click'); // also valid for user events

    Type Parameters

    • T

      Feature type surfaced by user interaction handlers.

    • CFG

      Module configuration type passed to config-change handlers.

    • TShown = never

      Data type passed to shown-features handlers. Use never for modules that have no show method.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Remove all handlers for the given event type at once.

      Accepts both user interaction types (click, contextmenu, hover, long-hover) and module lifecycle types (config-change, shown-features).

      Prefer the unsubscribe function returned by on when you need to remove a single handler. Use off for bulk teardown — e.g. when unmounting a component that registered multiple handlers of the same type.

      Parameters

      • type: "config-change" | "shown-features" | EventType

        The event type whose handlers should all be cleared.

      Returns void

      places.events.off('click');          // clear all click handlers
      places.events.off('config-change'); // clear all config-change handlers
    • Subscribe to a user interaction event (click, contextmenu, hover, long-hover).

      Parameters

      • type: EventType

        The user event type.

      • handler: UserEventHandler<T>

        Called with the feature, click/hover coordinates, all features at the point, and the source configuration.

      Returns () => void

      An unsubscribe function. Call it to remove only this handler.

      const unsub = places.events.on('click', (feature, lngLat) => {
      showPlaceDetails(feature.properties);
      });
      unsub(); // remove only this handler
    • Subscribe to config-change events.

      Fires after any configuration mutation — applyConfig, setVisible, or any module-specific setter. The handler receives the module's full updated configuration.

      Parameters

      • type: "config-change"

        'config-change'

      • handler: (config: CFG | undefined) => void

        Receives the module's config (or undefined when config is cleared).

      Returns () => void

      An unsubscribe function. Call it to remove only this handler.

      const unsub = trafficFlow.events.on('config-change', (config) => {
      toggle.checked = config?.visible ?? false;
      });
      unsub();
    • Subscribe to shown-features events.

      Fires immediately after the module's show() method (or equivalent) has rendered new data on the map. Only available on modules that have a show method.

      Parameters

      • type: "shown-features"

        'shown-features'

      • handler: (features: TShown) => void

        Receives the data that was passed to show().

      Returns () => void

      An unsubscribe function. Call it to remove only this handler.

      const unsub = places.events.on('shown-features', (features) => {
      fitMapToResults(features);
      });
      unsub();