backend-plugin-api: add doc for service factory initialization option

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-04-05 10:17:25 +02:00
parent d7de1a0f7a
commit 7a3684c60b
2 changed files with 20 additions and 2 deletions
@@ -438,7 +438,6 @@ export interface PluginServiceFactoryConfig<
deps: ServiceRefsToInstances<TDeps>,
context: TContext,
): TImpl | Promise<TImpl>;
// (undocumented)
initialization?: 'always' | 'lazy';
// (undocumented)
service: ServiceRef<TService, 'plugin'>;
@@ -519,7 +518,6 @@ export interface RootServiceFactoryConfig<
deps: TDeps;
// (undocumented)
factory(deps: ServiceRefsToInstances<TDeps, 'root'>): TImpl | Promise<TImpl>;
// (undocumented)
initialization?: 'always' | 'lazy';
// (undocumented)
service: ServiceRef<TService, 'root'>;
@@ -141,6 +141,16 @@ export interface RootServiceFactoryConfig<
TImpl extends TService,
TDeps extends { [name in string]: ServiceRef<unknown> },
> {
/**
* The initialization strategy for the service factory. This service is root scoped and will use `always` by default.
*
* @remarks
*
* - `always` - The service will always be initialized regardless if it is used or not.
* - `lazy` - The service will only be initialized if it is depended on by a different service or feature.
*
* Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`.
*/
initialization?: 'always' | 'lazy';
service: ServiceRef<TService, 'root'>;
deps: TDeps;
@@ -154,6 +164,16 @@ export interface PluginServiceFactoryConfig<
TImpl extends TService,
TDeps extends { [name in string]: ServiceRef<unknown> },
> {
/**
* The initialization strategy for the service factory. This service is plugin scoped and will use `lazy` by default.
*
* @remarks
*
* - `always` - The service will always be initialized regardless if it is used or not.
* - `lazy` - The service will only be initialized if it is depended on by a different service or feature.
*
* Service factories for root scoped services use `always` as the default, while plugin scoped services use `lazy`.
*/
initialization?: 'always' | 'lazy';
service: ServiceRef<TService, 'plugin'>;
deps: TDeps;