class FeatureFlagService
implements IFeatureFlags
Since 0.1.0

Feature flag service that delegates to a single FlagProvider.

Implements the synchronous IFeatureFlags contract; the provider owns a cached snapshot and refreshes it out of band via its own async lifecycle.

Examples

Example 1

const service = new FeatureFlagService(provider);
await service.start();
const on = service.isEnabled('new-dashboard', { userId: 'u1' });
await service.stop();

Constructors

FeatureFlagService(provider: FlagProvider)

Methods

isEnabled(
flag: string,
context?: FlagContext
): boolean

Evaluates whether a flag is enabled.

Since 0.2.0
isEnabledAsync(
flag: string,
context?: FlagContext
): Promise<boolean>

Evaluates a flag, awaiting the provider when it can answer asynchronously.

Both entry points funnel through the SAME provider instance, so a configured option — fallbackValue above all — governs identically whether a caller reaches for the synchronous or the asynchronous method. A provider with no async path resolves its synchronous evaluation, which for a purely local snapshot is already the correct answer.

start(): Promise<void>

Starts the underlying provider (pulls initial state).

Forwards the provider's optional health status.

stop(): Promise<void>

Stops the underlying provider (releases timers / connections).

Usage

import { FeatureFlagService } from "feature-flags-plugin/src/index.ts";