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,
|
options.existingUserPreferenceService,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const configServiceProviders = this._getConfigServiceProviders(options.configServiceFactory, options.configService);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ngModule: CommonUiModule,
|
ngModule: CommonUiModule,
|
||||||
providers: [
|
providers: [userPreferenceService, configServiceProviders],
|
||||||
userPreferenceService,
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static _getConfigServiceProviders(configServiceFactory: () => unknown, configService: unknown) {
|
||||||
|
if (configService) {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
provide: options.configService,
|
provide: configService,
|
||||||
useFactory: options.configServiceFactory,
|
useFactory: configServiceFactory,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: BaseConfigService,
|
provide: BaseConfigService,
|
||||||
useExisting: options.configService,
|
useExisting: configService,
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
provide: BaseConfigService,
|
||||||
|
useFactory: configServiceFactory,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,6 @@ export interface CommonUiOptions<
|
|||||||
AppConfig extends BaseAppConfig,
|
AppConfig extends BaseAppConfig,
|
||||||
> {
|
> {
|
||||||
existingUserPreferenceService?: Type<UserPreference>;
|
existingUserPreferenceService?: Type<UserPreference>;
|
||||||
configService: Type<Config>;
|
configService?: Type<Config>;
|
||||||
configServiceFactory: () => Config;
|
configServiceFactory: () => Config;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user