TomTom Maps for JavaScript
    Preparing search index...

    Class ModuleEvents<TConfig, TShownFeatures>

    Type Parameters

    • TConfig
    • TShownFeatures = never
    Index
    • Remove all handlers for the given event type at once.

      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.

      Parameters

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

        The event type whose handlers should all be cleared.

      Returns void

      // Clear all config-change listeners in one call
      trafficFlow.events.off('config-change');
    • Subscribe to config-change events.

      The handler is called with the module's full current configuration immediately after any mutation — whether through applyConfig, a module-specific setter, or resetConfig.

      Parameters

      • type: "config-change"

        'config-change'

      • handler: (config: TConfig | 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 without affecting other registered handlers for the same event type.

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

      // Later:
      unsub();
    • Subscribe to shown-features events.

      The handler is called immediately after a module's show() method (or equivalent) has updated the map with new data. Only available on modules that have a show method.

      Parameters

      Returns () => void

      An unsubscribe function. Call it to remove only this handler without affecting other registered handlers for the same event type.

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

      // Later:
      unsub();