make config service not required
This commit is contained in:
parent
e007d5fe57
commit
2d8c2e76c7
@ -95,19 +95,33 @@ export class CommonUiModule extends ModuleWithOptions {
|
||||
options.existingUserPreferenceService,
|
||||
);
|
||||
|
||||
const configServiceProviders = this._getConfigServiceProviders(options.configServiceFactory, options.configService);
|
||||
|
||||
return {
|
||||
ngModule: CommonUiModule,
|
||||
providers: [
|
||||
userPreferenceService,
|
||||
providers: [userPreferenceService, configServiceProviders],
|
||||
};
|
||||
}
|
||||
|
||||
private static _getConfigServiceProviders(configServiceFactory: () => unknown, configService: unknown) {
|
||||
if (configService) {
|
||||
return [
|
||||
{
|
||||
provide: options.configService,
|
||||
useFactory: options.configServiceFactory,
|
||||
provide: configService,
|
||||
useFactory: configServiceFactory,
|
||||
},
|
||||
{
|
||||
provide: BaseConfigService,
|
||||
useExisting: options.configService,
|
||||
useExisting: configService,
|
||||
},
|
||||
],
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
provide: BaseConfigService,
|
||||
useFactory: configServiceFactory,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,6 @@ export interface CommonUiOptions<
|
||||
AppConfig extends BaseAppConfig,
|
||||
> {
|
||||
existingUserPreferenceService?: Type<UserPreference>;
|
||||
configService: Type<Config>;
|
||||
configService?: Type<Config>;
|
||||
configServiceFactory: () => Config;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user