Lime Web Components API Documentation - v6.24.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

      Get all configuration data

      @State()
      @SelectConfig({})
      private config: Record<string, unknown>;

      render() {
      return (
      <div>
      <h2>Configuration</h2>
      <pre>{JSON.stringify(this.config, null, 2)}</pre>
      </div>
      );
      }

      Get specific config value by name

      @State()
      @SelectConfig({
      name: 'apiEndpoint',
      map: [(config) => config?.url || 'https://api.example.com']
      })
      private apiUrl: string;

      async fetchData() {
      const response = await fetch(`${this.apiUrl}/data`);
      return response.json();
      }