Angular
Installation
Add the OpenFeature SDK and the Tggl Provider to your project:
Quick start
First, import the OpenFeatureModule
and configure it using the forRoot
method:
You can now conditionally display content:
Conditional rendering
You can use four primary directives to conditionally display content, booleanFeatureFlag
, numberFeatureFlag
, stringFeatureFlag
and objectFeatureFlag
. The first value is always the flag's key, followed by the default value if the flag is not found.
For values other than boolean, the value to compare the evaluation result to can be provided by the value
parameter:
Getting a flag's value
You can use the same directives to get a flag's value:
Managing the context
You can update the context at any time to react to changes in your app:
setContext
is async and will return a promise that resolves once the flags for that new context have been fetched from the API. All your components will be re-rendered with the new flag values.
Polling for "live" updates
If you need your client to be up-to-date with the latest flag configuration, you can enable polling:
Here, the provider will poll the Tggl API every 5 seconds for updates. If one of the flag changes, any component that uses this flag will be re-rendered with the new value.
Using the Proxy
By default, the Provider talks directly to the Tggl API. If you are using the Tggl Proxy, you can specify the proxy URL when instantiating the provider:
The /flags
and /report
path will be appended to the baseUrl
and both flags evaluation and reporting will go through the proxy. If your proxy is configured with custom paths, you can specify them:
Going further
Read the official OpenFeature SDK documentation for more information on how to use the SDK.
You can also have a look at Tggl's Node.js SDK documentation that is used under the hood by the TgglWebProvider
.