Skip to content

viral98/feature-flags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FEATURE FLAGS

We use this system to define features that we can easily turn on and off, for testing or to put something temporarily on hold.

To define one, add it to the defaults object. The value must be a boolean.

Use it in TypeScript code:

import features from "ts-feature-flags";

function foo() {
if (features.enabled("bar")) {
    doSomething();
 }
}

Use it in TSX:

<div>
 {features.enabled("bar") && <Something />}
</div>

Use it in JavaScript code:

import features from "ts-feature-flags";

function foo() {
if (features.bar)) {
    doSomething();
 }
}

To set or unset them, open devtools, and:

features.foo = true;
features.bar = false;
features.unset('piyo'); // resets to default

Then you have to reload the page or restart the app. Intentionally the values are not changed on the fly, to avoid bugs with IPC, React update headaches, etc.

About

We use this system to define features that we can easily turn on and off, for testing or to put something temporarily on hold.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published