Setu-TS
    Preparing search index...

    Interface IFeatureFlags

    Feature flag evaluator. Evaluation is synchronous against the provider's cached state; providers refresh their state out of band.

    const flags = ctx.services.get<IFeatureFlags>(CAPABILITIES.FEATURE_FLAGS);
    if (flags.isEnabled('new-dashboard', { userId: user.id })) {
    return renderNewDashboard();
    }

    0.1.0

    interface IFeatureFlags {
        isEnabled(flag: string, context?: FlagContext): boolean;
        isEnabledAsync?(flag: string, context?: FlagContext): Promise<boolean>;
    }

    Implemented by

    Index
    • Evaluates a flag, awaiting the backing provider when it can produce a more accurate answer asynchronously.

      Optional, and additive: a provider with a purely local snapshot (config, memory, database polling) has nothing to await, so its implementation simply resolves IFeatureFlags.isEnabled. The method exists for providers whose SDK evaluates asynchronously — LaunchDarkly's server SDK being the motivating case — where the synchronous path must answer from a cached snapshot and therefore returns a configured fallback the first time it sees a given context.

      Prefer this method wherever a wrong answer on a cold context would matter (billing, entitlement, an irreversible action); prefer IFeatureFlags.isEnabled on hot paths that cannot await.

      Parameters

      • flag: string

        Flag name

      • Optionalcontext: FlagContext

        Targeting context

      Returns Promise<boolean>

      true when the flag is on for this context; unknown flags evaluate to false

      const flags = ctx.services.get<IFeatureFlags>(CAPABILITIES.FEATURE_FLAGS);
      const on = await flags.isEnabledAsync?.('new-billing', { userId: user.id });

      0.2.0