@one-view/flag
v0.3.3
Published
OneView Flag Loader
Downloads
850
Maintainers
Keywords
Readme
@one-view/flag
Installation
With NPM
$ npm install @one-view/flag
With Yarn
$ yarn add @one-view/flag
Usage
Flag.configure
import Flag from '@one-view/flag';
Flag.configure({
url: 'http://your-flag-url',
});
Flag.loadFlags()
Load all flags and store in browser memory
Return: Promise
Example:
Flag.loadFlags().then(() => {
renderApp();
});
Flag.getFlag(flagName, defaultValue?)
Get a single flag value, fallback to default value.
flagName
Type: string
defaultValue
Type: boolean
Example:
import Flag from '@one-view/flag';
const myFeatureFlag = Flag.getFlag('my-feature', false);
if (myFeatureFlag) {
console.log('do one thing');
} else {
console.log('do other thing');
}
Flag.setFlag(flagName, value)
Set value for a flag
Return: Promise
flagName
Type: string
value
Type: boolean
Example:
import Flag from '@one-view/flag';
Flag.setFlag('my-feature', true).then(() => {
console.log('Flag updated!');
});