Skip to main content

Feature toggle

Proposed change

We need a way to toggle feature on and off, this proposal introduces a library to help us do just that.

See how to guide for more information: how to - feature toggle

How it looks

In JSX:

import { Feature, FeatureToggle } from '@pm-netbank/feature-toggle';
...

<FeatureToggle feature={Feature.your_feature}>
<YourComponent />
</FeatureToggle>;

in TS:

import { FeatureToggleContext, Feature } from '@pm-netbank/feature-toggle';
...

const YourComponent = () => {
const { isOn } = useContext(FeatureToggleContext);

if (isOn(Feature.your_feature)) {
// Do something
}
});

Motivation

We're getting to a point where we need to start toggling on/off some features.

Setting off to create this library, we want to achieve to a few things.

  • An easy way to toggle on/off features.
  • Ability to change feature toggle services - for now we'll use a local setup, but we'll end up using a different service when it's been procured.
  • Make the intent of the code clear for any developer reading through.
  • Make the toggle easy to remove when it's no longer needed.
  • Easy to test
  • Something that would stand out when scanning the code.