blob: 09ce7bbf5974e60c7a88e8c18b74ec1c92e7622b [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {ElementRef, Injectable, Renderer2, RendererFactory2} from "@angular/core";
2import {ConfigurationService} from "../../shared/services/configuration.service";
3
4@Injectable()
5export class FeatureFlagService{
6 private features : { [key: string]: boolean } = {};
7 private renderer: Renderer2;
8 constructor(private _configurationService: ConfigurationService,
9 rendererFactory: RendererFactory2){
10 this.renderer = rendererFactory.createRenderer(null, null);
11 this._configurationService.getFlags().subscribe((res: { [key: string]: boolean }) =>{
12 this.features = res;
13 })
14 }
15
16
17 isFeatureOn(feature : string) : boolean {
18 return this.features && this.getFeatureFlag()[feature] === true;
19 }
20
21 getFeatureFlag() : { [key: string]: boolean } {
22 return this.features;
23 }
24
25 hideElement(element: ElementRef) {
26 this.renderer.setStyle(element.nativeElement, 'display', 'none');
27 }
28}