UNPKG

ngx-growthbook

Version:
60 lines (59 loc) 2.86 kB
import { OnDestroy } from '@angular/core'; import { GrowthBook, Context, Attributes, RefreshFeaturesOptions, FeatureResult } from '@growthbook/growthbook'; import { Observable } from 'rxjs'; import { NgxGrowthbookConfiguration, TrackingService } from './ngx-growthbook.config'; import * as i0 from "@angular/core"; export { type FeatureResult, type Result } from '@growthbook/growthbook'; export declare class NgxGrowthbookService implements OnDestroy { private config; private growthBook; private readonly growthBookSource; private eventCount; private readonly destroy$; constructor(config: NgxGrowthbookConfiguration); ngOnDestroy(): void; init(config: Context, trackingService?: TrackingService | null): Promise<GrowthBook<Record<string, any>>>; triggerUpdate(): void; subscribe(callback: (n: number) => void): import("rxjs").Subscription; getFeature<T>(featureKey: string, defaultValue?: T): FeatureResult<T>; /** * Evaluates a feature and returns an observable that will emit whenever the feature changes * @param featureKey The feature key to evaluate * @param defaultValue The default value if the feature is not found */ evaluateFeature<T>(featureKey: string, defaultValue?: T): Observable<FeatureResult<T>>; /** * Evaluates a feature and returns the current value synchronously * @param featureKey The feature key to evaluate * @param defaultValue The default value if the feature is not found */ evaluateFeatureSync<T>(featureKey: string, defaultValue?: T): FeatureResult<T>; loadFeatures(): Promise<void>; isOn(featureKey: string): boolean; isOff(featureKey: string): boolean; setFeatureValue(featureKey: string): void; getFeatureValue(featureKey: string, defaultValue: any): any; /** * In addition to the isOn and getFeatureValue helper methods, * there is the evalFeature method that gives you more detailed * information about why the value was assigned to the user. * @param featureKey * @returns */ evalFeature(featureKey: string): FeatureResult<any>; /** * Completely replaces attributes * @param attributes */ setAttributes(attributes: Attributes): Promise<void>; updateAttributes(attributes: Attributes): Promise<void>; refreshFeatures(options?: RefreshFeaturesOptions): Promise<void>; setURL(url: string): Promise<void>; getAttributes(): { [x: string]: any; }; getFeatures(): Record<string, import("@growthbook/growthbook").FeatureDefinition<any>>; getExperiments(): import("@growthbook/growthbook").AutoExperiment<import("@growthbook/growthbook").AutoExperimentVariation>[]; static ɵfac: i0.ɵɵFactoryDeclaration<NgxGrowthbookService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NgxGrowthbookService>; }