jrmmendes / feature-toggles

Simple library that provides a minimum interface to fetch and decide feature flags

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Toggle Library

This simple library provides an agnostic data fetching interface (WIP) and a decision service.

Feature Toggle Decisions

To make use of the decision service, you need to fetch the flags from you source, with the following interface:

export interface FeatureFlag {
  active: boolean;
  feature: string;
  enabledAndroid?: boolean;
  enablediOS?: boolean;
  enabledWeb?: boolean;
  allowMobileFromVersion?: string;
  roles?: Role[];
  gvCodes?: number[];
  release?: ReleaseOptions[];
  countries?: Country[];
}

You can find the enums, nested types and field descriptions on interfaces.ts file.

Then, you must create a DecisionService instance and use the isEnabled method. This method receives two parameters:

  • the feature flag name;
  • the context to be used on the decision;
import {DecisionService} from "@squad-fv/feature-flags";

const flags = yourConnector.getFlags();
const service = new DecisionService(flags);

// ... later on your code

const isFeatureFlagEnabled = service.isEnabled('FEATURE_TOGGLE_NAME', context);

You can also find the context interface on the interfaces.ts file.

Roadmap

  • Country based decisions;
  • Release based decisions;
  • Flag fetching from remote backends;
  • Type support for flag names for isEnabled method;
  • Service level context support

About

Simple library that provides a minimum interface to fetch and decide feature flags


Languages

Language:TypeScript 97.9%Language:JavaScript 2.1%