src/app/core/common-components/entities-table/data-source/data-source-registry.ts
The data sources that the dataSource of a list or related-entities config can name.
Core registers "in-memory" and "paginated" here, feature modules add their own data sources in their module:
Example :inject(DataSourceRegistry).add("my-feature", MyFeatureDataSource);
Registry<DataSourceConstructor>
| providedIn | root |
No results matching.
Properties |
|
Methods |
|
constructor()
|
| Public add | |||||||||
add(key: string, mapping: T)
|
|||||||||
|
Inherited from
Registry
|
|||||||||
|
Parameters :
Returns :
void
|
| Public addAll | ||||||
addAll(tuples: unknown[])
|
||||||
|
Inherited from
Registry
|
||||||
|
Parameters :
Returns :
void
|
| Public allowDuplicates | ||||||||
allowDuplicates(allow: boolean)
|
||||||||
|
Inherited from
Registry
|
||||||||
|
Calling this will allow the same keys to be added multiple times without thrown errors. This is useful for storybook where live-updates re-trigger the decorator while the registry is cached.
Parameters :
Returns :
void
|
| Public get | ||||||
get(key: string)
|
||||||
|
Inherited from
Registry
|
||||||
|
Parameters :
Returns :
T
|
| Protected Readonly registryName |
Type : string
|
Default value : "DataSourceRegistry"
|
|
Inherited from
Registry
|
import { Injectable } from "@angular/core";
import { Registry } from "#src/app/core/config/registry/dynamic-registry";
import { Entity } from "#src/app/core/entity/model/entity";
import { EntitiesTableDataSource } from "./entities-table-data-source";
import { InMemoryDataSource } from "./in-memory-data-source";
import { PaginatedDataSource } from "./paginated-data-source";
/** A concrete data source class, created in an injection context by `resolveDataSource`. */
export type DataSourceConstructor = new <
T extends Entity,
>() => EntitiesTableDataSource<T>;
/**
* A data source named in a list or section config together with options for it:
* `"dataSource": { "name": "my-feature", "config": { "someOption": true } }`.
* (A plain name, `"dataSource": "my-feature"`, is the same without options.)
*/
export interface DataSourceConfig<C extends object = Record<string, unknown>> {
/** name of the data source in the {@link DataSourceRegistry} */
name: string;
/** options that the data source reads itself (see `EntitiesTableDataSource.config`) */
config?: C;
}
/**
* The data sources that the `dataSource` of a list or related-entities config can name.
*
* Core registers "in-memory" and "paginated" here,
* feature modules add their own data sources in their module:
* ```
* inject(DataSourceRegistry).add("my-feature", MyFeatureDataSource);
* ```
*/
@Injectable({ providedIn: "root" })
export class DataSourceRegistry extends Registry<DataSourceConstructor> {
protected override readonly registryName = "DataSourceRegistry";
constructor() {
super();
this.addAll([
["in-memory", InMemoryDataSource],
["paginated", PaginatedDataSource],
]);
}
}