@farmart-tech/brave-firebase-adapter
    Preparing search index...

    Class FeatureFlagReader

    Firebase-backed reader for feature flags, segments, and conditions.

    This class provides methods to fetch and subscribe to feature flag data from Firestore. it handles workspace fallbacks (global vs specific) and maintains an internal cache for performance.

    const reader = new FeatureFlagReader({
    db: firestoreInstance,
    workspace: 'production',
    userContext: { userId: 'user-123' }
    });

    const isEnabled = await reader.getFeatureFlag('new_feature').then(f => f?.getIsEnabled());

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    db: FirestoreDb
    prefetchPromise: Promise<unknown> | null = null
    Feature: typeof Feature = Feature

    Methods

    • Type Parameters

      • T
      • D

      Parameters

      • collection: string
      • factory: (key: string, data: D) => T
      • cache: Map<string, D>
      • allLoaded: boolean
      • useCache: boolean = true

      Returns Promise<Record<string, T> | null>

    • Subscribes to real-time updates for a single feature flag.

      Parameters

      • flagName: string

        Name of the flag to watch

      • onChange: (feature: Feature | null) => void

        Callback triggered when the flag data changes

      • OptionalonError: (error: Error) => void

        Optional error callback

      Returns Unsubscribe

      Unsubscribe function

    • Subscribes to real-time updates for all feature flags in the workspace.

      Parameters

      • onChange: (features: Record<string, Feature>) => void

        Callback triggered when any flag in the collection changes

      • OptionalonError: (error: Error) => void

        Optional error callback

      Returns Unsubscribe

      Unsubscribe function