Created
November 11, 2021 19:51
-
-
Save mts88/bc0577b4826de56ac58d3cec67f36b29 to your computer and use it in GitHub Desktop.
Feature Flag Service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { IMutableContext, UnleashClient } from 'unleash-proxy-client'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class FeatureFlagService { | |
unleash = new UnleashClient({ | |
url: `http://localhost:3000/proxy`, // url to Unleash Proxy | |
clientKey: `my_secret_for_client`, // secret used in docker env UNLEASH_PROXY_SECRETS | |
appName: `development`, // the appName used in docker env UNLEASH_APP_NAME | |
environment: `development`, // you can configure it easily in environment.ts and environment.prod.ts | |
}); | |
constructor() {} | |
start(): void { | |
this.unleash.start(); | |
} | |
stop(): void { | |
this.unleash.stop(); | |
} | |
updateContext(contextObj: IMutableContext): void { | |
this.unleash.updateContext(contextObj); | |
} | |
isEnabled(feature: string): boolean { | |
return this.unleash.isEnabled(feature); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment