Lime Web Components API Documentation - v7.4.0
    Preparing search index...

    Function SelectConfig

    • Decorator that subscribes to configuration data from the ConfigRepository.

      This decorator automatically updates the decorated property whenever configuration data changes in the platform. Returns an object with all configs where the config key is used as the key. It's the recommended approach over manual subscriptions as it handles subscription lifecycle automatically.

      Parameters

      Returns PropertyDecorator

      A PropertyDecorator that sets up automatic subscription to config data

      Subscribes to: ConfigRepository

      Updates: The decorated property with configuration data (object or specific value)

      Lifecycle: Automatically subscribes in connectedCallback and unsubscribes in disconnectedCallback

      import { State } from '@stencil/core';
      import { SelectConfig } from '@limetech/lime-web-components';

      class MyConfigComponent {
      // Every config the platform holds, keyed by config name
      @State()
      @SelectConfig({})
      private configs: Record<string, unknown>;
      }
      import { State } from '@stencil/core';
      import { SelectConfig } from '@limetech/lime-web-components';

      class MyApiComponent {
      // The name narrows the state to that one config, so map receives the config
      // value itself and not the whole config object
      @State()
      @SelectConfig({
      name: 'apiEndpoint',
      map: [(config) => config?.url || 'https://api.example.com'],
      })
      private apiUrl: string;
      }