bower install featuretoggle-lib-js-2


Feature Toggle

A Javascript client library for interacting with featuretoggle.com. This library is under active development and is likely to change frequently. Bug reports and pull requests are welcome.


Install with Bower

bash bower install featuretoggle-lib-js

Install with NPM

bash npm install featuretoggle-lib-js


```javascript // Create instance var ft = new FeatureToggle('customerKey', 'environmentKey', {options});

var myFeature, myFeatures;

// Get features list ft.getFeatures(function(error,features){ if(error !== null) { console.log(error); } else { myFeatures = features; } });

// Check if specific feature is active if(myFeatures['feature-name']) { console.log('Feature is active, run code'); }

// Get status of specific feature ft.isEnabled('feature-name',function(error,enabled){ if(error !== null) { console.log(error); } else { myFeature = enabled; } });

// Check if single feature is active if(myFeature) { console.log('Feature is active, run code'); }


Configuration Options

The library caches responses from received the Feature Toggle API locally to limit the number of requests. The default cache timeout is 300 seconds (5 minutes). You can adjust the cache timeout by providing the 'cache_timeout' config option when initializing the library.

```javascript { /** * Authentication token (required) * * You can obtained this token from the FeatureToggle backend */ auth: 'STRING',

 * API version to use (optional, default: '1.0')
 * WARNING: changing this value may prevent you from accessing
 * the API if you supply an invalud version number
version: 'STRING',

 * Cache timeout value in seconds (optional, default: 300)
cache_timeout: SECONDS

} ```


Bug reports and pull requests are welcome on GitHub at https://github.com/featuretoggle/lib-js.


The library is available as open source under the terms of the MIT License.