Skip to content

Instantly share code, notes, and snippets.

@buildmotion
Created June 20, 2019 06:38
Show Gist options
  • Save buildmotion/7898f251656b61ae9227be550c056055 to your computer and use it in GitHub Desktop.
Save buildmotion/7898f251656b61ae9227be550c056055 to your computer and use it in GitHub Desktop.
A Configuration service that provides the configuration context to libraries in the application workspace.
import { Injectable, Optional } from "@angular/core";
import { ConfigurationContext } from "./configuration-context";
import { Subject, ReplaySubject } from "rxjs";
import { IConfiguration } from "./i-configuration";
@Injectable({
providedIn: "root"
})
export class ConfigurationService {
settings$: Subject<IConfiguration> = new ReplaySubject<IConfiguration>(1);
constructor(@Optional() context: ConfigurationContext) {
if (context) {
this.settings$.next(context.config);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment