Link Search Menu Expand Document

Using flags

This page explains how to use retrieve and use feature flags in your JavaScript application.

Getting feature flags

To load a feature flag, use the getFlag() function.

AppFlags.getFlag("flag_key", flag => {
    const value = flag.value;
});

Subscribing to feature flag changes

To subscribe to feature flag changes, use the onFlagChanged() function.

AppFlags.onFlagChanged("flag_key", flag => {
    const value = flag.value;
});

Note that onFlagChanged() immediately resolves with the feature flag’s current value.

If the feature flag is updated, the subscription will be invoked within a few seconds with the flag’s updated value.

Using the feature flag

To get the value of the feature flag variation, use the value property.

The value property will be a boolean, number, or string based on the flag’s variation type. See Variation types.

For example, a boolean flag could be used like this:

AppFlags.getFlag("feature_toggle", flag => {
    const featureEnabled = flag.value;
});

© 2020 AppFlags