Skip to main content

FeatureFlagStore

@quik/core


@quik/core / FeatureFlagStore

Variable: FeatureFlagStore

FeatureFlagStore: object

Defined in: features/QFeatureFlag.ts:172

Feature flag management interface.

Type Declaration​

active​

active: () => string[] = listActiveFlags

Returns an array of all active (enabled) feature flag names.

This function returns a list of only the feature flag names that are currently enabled (set to true).

Returns​

string[]

Example​

const activeFlags = QFeatureFlag.active();
console.log(activeFlags); // ['enabled-feature-a', 'enabled-feature-b']

See​

  • listFlags For getting names of all flags regardless of state
  • getAllFlags For getting both names and values of all flags

all​

all: () => Record<string, boolean> = getAllFlags

Returns a copy of all feature flags and their values.

This function returns a new object containing all currently set feature flags and their boolean values. The returned object is a shallow copy to prevent direct modification of the internal flags state.

Returns​

Record<string, boolean>

Example​

const allFlags = QFeatureFlag.all();
console.log(allFlags); // { 'feature-a': true, 'feature-b': false }

See​

listFlags For getting only the names of all flags

clear​

clear: () => void = clearFlags

Clears all feature flags.

This function resets all feature flags to their initial state, effectively disabling all features.

Returns​

void

Example​

QFeatureFlag.clear();
// All feature flags are now reset

See​

setFlag For setting individual flags

disable​

disable: (name) => void = disableFlag

Disables a feature flag.

Parameters​

name​

string

The name of the feature flag to disable

Returns​

void

Example​

QFeatureFlag.disable('beta-features');

See​

setFlag For setting a flag to a specific value

enable​

enable: (name) => void = enableFlag

Enables a feature flag.

Parameters​

name​

string

The name of the feature flag to enable

Returns​

void

Example​

QFeatureFlag.enable('dark-mode');

See​

setFlag For setting a flag to a specific value

flags​

flags: () => string[] = listFlags

Returns an array of all feature flag names.

This function returns a list of all currently set feature flag names, regardless of whether they are enabled or disabled.

Returns​

string[]

Example​

const flagNames = QFeatureFlag.flags();
console.log(flagNames); // ['feature-a', 'feature-b']

See​

getAllFlags For getting both names and values of all flags

has​

has: (name) => boolean = hasFlag

Checks if a feature flag is enabled.

Parameters​

name​

string

The name of the feature flag to check

Returns​

boolean

Example​

if (QFeatureFlag.has('new-ui')) {
// Show new UI components
}

loadFromConfig​

loadFromConfig: (flags) => void

Load feature flags from a plain flags object. Each key is a flag name; truthy values enable the flag. Typically called with getConfig().object("featureFlags", {}).

Parameters​

flags?​

Record<string, unknown> = {}

Map of flag names to boolean values.

Returns​

void

Example​

FeatureFlagStore.loadFromConfig(getConfig().object("featureFlags", {}));

set​

set: (name, defaultValue?) => void = setFlag

Sets a feature flag to a specific value.

Parameters​

name​

string

The name of the feature flag to set

defaultValue?​

boolean

Optional default value for the flag (defaults to false)

Returns​

void

Example​

QFeatureFlag.set('experimental-feature', true);

See​