Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 195x 195x 195x 195x 195x 195x 195x 195x 155x 155x 265x 24x 168x 1114x 225x | import { ModuleWithProviders, NgModule } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; import { map } from 'rxjs/operators'; import { FeatureToggleDirective } from './directives/feature-toggle.directive'; import { NotFeatureToggleDirective } from './directives/not-feature-toggle.directive'; import { FeatureToggleService, FeatureToggleType, checkFeature } from './utils/feature-toggle/feature-toggle.service'; @NgModule({ declarations: [FeatureToggleDirective, NotFeatureToggleDirective], exports: [FeatureToggleDirective, NotFeatureToggleDirective], }) export class FeatureToggleModule { private static features$ = new BehaviorSubject<FeatureToggleType[]>(undefined); static forTesting(...features: FeatureToggleType[]): ModuleWithProviders<FeatureToggleModule> { FeatureToggleModule.switchTestingFeatures(...features); return { ngModule: FeatureToggleModule, providers: [ { provide: FeatureToggleService, useValue: { enabled$: (feature: FeatureToggleType) => FeatureToggleModule.features$.pipe(map(toggles => checkFeature(toggles, feature))), // eslint-disable-next-line rxjs/no-subject-value enabled: (feature: FeatureToggleType) => checkFeature(FeatureToggleModule.features$.value, feature), }, }, ], }; } static switchTestingFeatures(...features: FeatureToggleType[]) { FeatureToggleModule.features$.next(features); } } export { FeatureToggleService, type FeatureToggleType } from './utils/feature-toggle/feature-toggle.service'; export { featureToggleGuard } from './guards/feature-toggle.guard'; |