18.0.1 • Published 1 year ago

@deejayy/reactive-config v18.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm

Runtime Reactive Configuration Handler for Angular

Install

npm i @deejayy/reactive-config

Define your configuration type

export class ConfigVars {
  public apiUrl!: string;
}

Add module to imports

imports: [
  ...
  ReactiveConfigModule.forRoot(ConfigVars, { configPath: '/assets/config-new.json' }),
],

Create configuration file with the fields defined in your type

/assets/config-new.json:

{
  "apiUrl": "http://localhost"
}

Use the config values from anywhere

Static variable: {{ apiUrl }}
Reactive variable: {{ apiUrl$ | async }}
public apiUrl: string = this.config.get('apiUrl'); // gets the latest value statically
public apiUrl$: Observable<string> = this.config.getStream('apiUrl'); // get values reactively with streams

constructor (private config: ReactiveConfigService<ConfigVars>) {}

Update the values runtime

<button (click)="updateVar()">change</button>
public updateVar() {
  this.config.set('apiUrl', 'new value');
}
18.0.1

1 year ago

18.0.0

1 year ago

17.0.0

2 years ago

16.0.0

2 years ago

15.0.0

2 years ago

14.0.3

3 years ago

14.0.2

3 years ago

14.0.1

3 years ago

14.0.0

3 years ago