This is the documentation of version 1.0.0-rc.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Class ModuleEvents<TConfig, TShownFeatures>

    Type Parameters

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

      To remove a single handler, call the unsubscribe function that on returns instead. Use off for bulk teardown, for example when unmounting a component that registered several 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');
    • Subscribes to config-change events.

      The handler receives the module's full current configuration right after any change made with 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 the config is cleared.

      Returns () => void

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

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

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

      The handler is called right after a module's show() method, or its equivalent, updates the map with new data. Only modules that have a show method offer it.

      Parameters

      Returns () => void

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

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

      // Later:
      unsub();