An open API service indexing awesome lists of open source software.

https://github.com/viral98/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.
https://github.com/viral98/feature-flags

feature-flag feature-flags typescript

Last synced: over 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

## 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:

```typescript
import features from "ts-feature-flags";

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

Use it in TSX:
```typescript


{features.enabled("bar") && }

```

Use it in JavaScript code:
```javascript
import features from "ts-feature-flags";

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

To set or unset them, open devtools, and:
```javascript
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.