blob: 09ce7bbf5974e60c7a88e8c18b74ec1c92e7622b [file] [log] [blame]
import {ElementRef, Injectable, Renderer2, RendererFactory2} from "@angular/core";
import {ConfigurationService} from "../../shared/services/configuration.service";
@Injectable()
export class FeatureFlagService{
private features : { [key: string]: boolean } = {};
private renderer: Renderer2;
constructor(private _configurationService: ConfigurationService,
rendererFactory: RendererFactory2){
this.renderer = rendererFactory.createRenderer(null, null);
this._configurationService.getFlags().subscribe((res: { [key: string]: boolean }) =>{
this.features = res;
})
}
isFeatureOn(feature : string) : boolean {
return this.features && this.getFeatureFlag()[feature] === true;
}
getFeatureFlag() : { [key: string]: boolean } {
return this.features;
}
hideElement(element: ElementRef) {
this.renderer.setStyle(element.nativeElement, 'display', 'none');
}
}