File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
packages/angular/projects/angular-sdk/src/lib Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 11import { InjectionToken , ModuleWithProviders , NgModule } from '@angular/core' ;
22import { CommonModule } from '@angular/common' ;
3- import { OpenFeature , Provider } from '@openfeature/web-sdk' ;
3+ import { EvaluationContext , OpenFeature , Provider } from '@openfeature/web-sdk' ;
4+
5+ export type EvaluationContextFactory = ( ) => EvaluationContext ;
46
57export interface OpenFeatureConfig {
68 provider : Provider ;
79 domainBoundProviders ?: Record < string , Provider > ;
10+ context ?: EvaluationContext | EvaluationContextFactory ;
811}
912
1013export const OPEN_FEATURE_CONFIG_TOKEN = new InjectionToken < OpenFeatureConfig > ( 'OPEN_FEATURE_CONFIG_TOKEN' ) ;
@@ -16,7 +19,9 @@ export const OPEN_FEATURE_CONFIG_TOKEN = new InjectionToken<OpenFeatureConfig>('
1619} )
1720export class OpenFeatureModule {
1821 static forRoot ( config : OpenFeatureConfig ) : ModuleWithProviders < OpenFeatureModule > {
19- OpenFeature . setProvider ( config . provider ) ;
22+ const context = typeof config . context === 'function' ? config . context ( ) : config . context ;
23+ OpenFeature . setProvider ( config . provider , context ) ;
24+
2025 if ( config . domainBoundProviders ) {
2126 Object . entries ( config . domainBoundProviders ) . map ( ( [ domain , provider ] ) =>
2227 OpenFeature . setProvider ( domain , provider ) ,
You can’t perform that action at this time.
0 commit comments