mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Make PassthroughStore generic
This commit is contained in:
parent
0ed1ae539d
commit
3d9507879b
@ -10,10 +10,10 @@ import { ResourceStore } from './ResourceStore';
|
||||
* Can be extended by stores that do not want to override all functions
|
||||
* by implementing a decorator pattern.
|
||||
*/
|
||||
export class PassthroughStore implements ResourceStore {
|
||||
protected readonly source: ResourceStore;
|
||||
export class PassthroughStore<T extends ResourceStore = ResourceStore> implements ResourceStore {
|
||||
protected readonly source: T;
|
||||
|
||||
public constructor(source: ResourceStore) {
|
||||
public constructor(source: T) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,10 @@ import { ResourceStore } from './ResourceStore';
|
||||
* If the original store supports the {@link Patch}, behaviour will be identical,
|
||||
* otherwise the {@link PatchHandler} will be called instead.
|
||||
*/
|
||||
export class PatchingStore extends PassthroughStore {
|
||||
export class PatchingStore<T extends ResourceStore = ResourceStore> extends PassthroughStore<T> {
|
||||
private readonly patcher: PatchHandler;
|
||||
|
||||
public constructor(source: ResourceStore, patcher: PatchHandler) {
|
||||
public constructor(source: T, patcher: PatchHandler) {
|
||||
super(source);
|
||||
this.patcher = patcher;
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ import { ResourceStore } from './ResourceStore';
|
||||
* Even if there is a match with the output from the store,
|
||||
* if there is a low weight for that type conversions might still be preferred.
|
||||
*/
|
||||
export class RepresentationConvertingStore extends PassthroughStore {
|
||||
export class RepresentationConvertingStore<T extends ResourceStore = ResourceStore> extends PassthroughStore<T> {
|
||||
private readonly converter: RepresentationConverter;
|
||||
|
||||
public constructor(source: ResourceStore, converter: RepresentationConverter) {
|
||||
public constructor(source: T, converter: RepresentationConverter) {
|
||||
super(source);
|
||||
this.converter = converter;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user