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 1
1
import { InjectionToken , ModuleWithProviders , NgModule } from '@angular/core' ;
2
2
import { 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 ;
4
6
5
7
export interface OpenFeatureConfig {
6
8
provider : Provider ;
7
9
domainBoundProviders ?: Record < string , Provider > ;
10
+ context ?: EvaluationContext | EvaluationContextFactory ;
8
11
}
9
12
10
13
export 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>('
16
19
} )
17
20
export class OpenFeatureModule {
18
21
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
+
20
25
if ( config . domainBoundProviders ) {
21
26
Object . entries ( config . domainBoundProviders ) . map ( ( [ domain , provider ] ) =>
22
27
OpenFeature . setProvider ( domain , provider ) ,
You can’t perform that action at this time.
0 commit comments