File

src/lib/config-testing-service.ts

Index

Properties
Methods

Methods

clearLocalConfig
clearLocalConfig()
Returns : void
get
get(propertyPath: string, defaultValue?: T)
Type parameters :
  • T
Parameters :
Name Type Optional
propertyPath string No
defaultValue T Yes
Returns : T | undefined
getOrThrow
getOrThrow(propertyPath: string)
Type parameters :
  • T
Parameters :
Name Type Optional
propertyPath string No
Returns : T
set
set(propertyPath: string, value: T)
Type parameters :
  • T
Parameters :
Name Type Optional
propertyPath string No
value T No
Returns : void
setLocalConfig
setLocalConfig(config: Record)
Parameters :
Name Type Optional
config Record<string | any> No
Returns : void

Properties

Readonly config
Type : Record<string | any>
Default value : {}
import { Injectable } from '@angular/core';
import {
  getFromObject,
  SetToObject,
} from '@rxap/utilities';
import { ConfigService } from './config.service';

@Injectable()
export class ConfigTestingService implements ConfigService {
  readonly config: Record<string, any> = {};

  // eslint-disable-next-line @typescript-eslint/no-empty-function
  clearLocalConfig(): void {
  }

  set<T>(propertyPath: string, value: T): void {
    SetToObject(this.config, propertyPath, value);
  }

  get<T>(propertyPath: string, defaultValue?: T): T | undefined {
    return getFromObject<T, T>(this.config, propertyPath, defaultValue);
  }

  getOrThrow<T>(propertyPath: string): T {
    const value = this.get<T>(propertyPath);
    if (value === undefined) {
      throw new Error(`Could not find config in path '${ propertyPath }'`);
    }
    return value;
  }

  // eslint-disable-next-line @typescript-eslint/no-empty-function
  setLocalConfig(config: Record<string, any>): void {
  }
}

results matching ""

    No results matching ""