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.
- Host: GitHub
- URL: https://github.com/viral98/feature-flags
- Owner: viral98
- Created: 2022-02-14T17:19:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-22T00:41:43.000Z (over 4 years ago)
- Last Synced: 2025-03-18T15:11:52.255Z (over 1 year ago)
- Topics: feature-flag, feature-flags, typescript
- Language: TypeScript
- Homepage:
- Size: 3.36 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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.