1.1.3 • Published 8 years ago

@leisurelink/feature-flag-client v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
8 years ago

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