Skip to main content
Skip to main content

FlagRouter

Implements

Constructors

constructor

**new FlagRouter**(flags)

Parameters

flagsRecord<string, boolean \| Record&#60;string, boolean&#62;>Required

Properties

flagsanyRequired

Methods

isFeatureEnabled

**isFeatureEnabled**(flag): boolean

Check if a feature flag is enabled. There are two ways of using this method:

  1. isFeatureEnabled("myFeatureFlag")
  2. isFeatureEnabled({ myNestedFeatureFlag: "someNestedFlag" }) We use 1. for top-level feature flags and 2. for nested feature flags. Almost all flags are top-level. An example of a nested flag is workflows. To use it, you would do: isFeatureEnabled({ workflows: Workflows.CreateCart })

Parameters

flagstring | Record<string, string>Required
The flag to check

Returns

boolean

booleanboolean
Whether the flag is enabled or not

listFlags

**listFlags**(): [FeatureFlagsResponse](/references/services/types/FeatureFlagsResponse)

Returns

FeatureFlagsResponse

FeatureFlagsResponse{ key: string ; value: boolean \| Record&#60;string, boolean&#62; }[]Required

setFlag

**setFlag**(key, value): void

Sets a feature flag. Flags take two shapes: setFlag("myFeatureFlag", true) setFlag("myFeatureFlag", { nestedFlag: true }) These shapes are used for top-level and nested flags respectively, as explained in isFeatureEnabled.

Parameters

keystringRequired
The key of the flag to set.
valueboolean | { [key: string]: boolean; }Required
The value of the flag to set.

Returns

void

voidvoid
void
Was this section helpful?