@leisurelink/feature-flag-client

LeisureLink client library to the feature-flag-api

Usage no npm install needed!

<script type="module">
  import leisurelinkFeatureFlagClient from 'https://cdn.skypack.dev/@leisurelink/feature-flag-client';
</script>

README

feature-flag-client

constructor

similar to any other trusted client

var featureFlagClient = new FeatureFlagClient(config.featureFlagUri, config.trustedId, config.trustedKey, console);

caching subscriber

the new preferred method to check flags is to use our caching subscriber... which will keep a local cache of flags that you can synchronously query:

var subscriber = featureFlagClient.getStreamSubscriber();

if (subscriber.getFlagValue('api.feature1')) {
    // feature1 is enabled!
} else {
    // no feature1 for you!
}

// or...
var flag = subscriber.getFlag('api.feature1');
if (flag && flag.value) {
    // feature1 is enabled!
}

subscription events

if by chance you need events, you can:

// subscribe to a specific flag
subscriber.onFlagId('api.feature', function(flag) {
    if (flag.deleted) {
        // flag deleted!
    } else {
        if (flag.value) {
            // flag is set!
        }
    }
});

// or subscribe to all flags
subscriber.onFlag(function(flag) {
    console.log(flag);
});

the CRUD methods

see the index.js for all the standard CRUD methods or check out the CLI