Skip to main content

GdConfigStore

The GdConfigStore is a signal-based store using NgRx Signals to manage application configuration state.

Import

import { GdConfigStore } from '@geodome/gdk/core';

Description

This store manages the application's configuration state, specifically the baseUrl. It uses NgRx Signals for state management, providing reactive and efficient state updates.

State Interface

interface ConfigState {
baseUrl: string | null;
}

Initial State

const initialState: ConfigState = {
baseUrl: null,
};

Methods

setBaseUrl(url: string)

Sets the baseUrl in the store.

clearConfig()

Resets the store to its initial state.

Usage

Inject the store in your component or service:

export class MyComponent {
private configStore = inject(GdConfigStore);

constructor() {
// Access the baseUrl
const baseUrl = this.configStore.baseUrl();

// Set a new baseUrl
this.configStore.setBaseUrl('https://api.example.com');

// Clear the config
this.configStore.clearConfig();
}
}

Key Features

  • Uses NgRx Signals for efficient state management.
  • Provides methods to set and clear configuration.
  • Automatically provided at the root level.
note

This store is typically used in conjunction with GdSettingsService for managing application-wide configuration.