add ContextToken

This commit is contained in:
Jacob Overgaard
2023-01-17 10:00:22 +01:00
parent 2151097a26
commit 87f2881a8f
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
export class ContextToken<T> {
/**
* @param _desc Description for the token,
* used only for debugging purposes,
* it should but does not need to be unique
*/
constructor(protected _desc: string) {}
/**
* @internal
*/
get multi(): ContextToken<Array<T>> {
return this as ContextToken<Array<T>>;
}
toString(): string {
return `${ContextToken.name} ${this._desc}`;
}
}

View File

@@ -2,3 +2,4 @@ export * from './consume/context-consumer';
export * from './consume/context-request.event';
export * from './provide/context-provider';
export * from './provide/context-provide.event';
export * from './context-token';