mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 14:01:44 +03:00
.. | ||
src | ||
.babelrc | ||
.eslintrc.json | ||
jest.config.ts | ||
package.json | ||
project.json | ||
README.md | ||
tsconfig.json | ||
tsconfig.lib.json | ||
tsconfig.spec.json |
Feature Flags
Usage
- set provider
import { FeatureFlagsProvider } from '@toeverything/datasource/feature-flags';
const App = () => {
return (
<FeatureFlagsProvider>
<Page />
</FeatureFlagsProvider>
);
};
- use flag
import { useFlag } from '@toeverything/datasource/feature-flags';
const App = () => {
// flag key, default value
const flag1 = useFlag('flag1', false);
// ^? boolean
const flag2 = useFlag<boolean>('flag2');
// ^? boolean | undefined
return flag1 && <div>The flag1 is enable!</div>;
};
How to add a new feature flag?
- Enter Portal
- Click
New Switch
button- Input
Switch Name
, and Enter - Adjust data and save
- Input
Test flags
When entering development mode feature flag will NOT be updated in real time
activateFfcDevMode()
play with feature flags locallyquitFfcDevMode()
quit dev mode
Running unit tests
Run nx test datasource/feature-flags
to execute the unit tests via Jest.