FlagRouter
Implements
Constructors
constructor
**new FlagRouter**(flags)
Parameters
flags
Record<string, boolean \| Record<string, boolean>>RequiredProperties
flags
anyRequiredMethods
isFeatureEnabled
**isFeatureEnabled**(flag): boolean
Check if a feature flag is enabled. There are two ways of using this method:
isFeatureEnabled("myFeatureFlag")
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
flag
string | Record<string, string>RequiredThe flag to check
Returns
boolean
boolean
boolean
Whether the flag is enabled or not
listFlags
**listFlags**(): [FeatureFlagsResponse](/references/services/types/FeatureFlagsResponse)
Returns
FeatureFlagsResponse
{ key: string ; value: boolean \| Record<string, boolean> }[]RequiredsetFlag
**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
key
stringRequiredThe key of the flag to set.
value
boolean | { [key: string]: boolean; }RequiredThe value of the flag to set.
Returns
void
void
void
void
Was this section helpful?