rename ContextToken to ContextAlias

This commit is contained in:
Jacob Overgaard
2023-01-17 11:06:17 +01:00
parent 14e63f7abb
commit 21b37f303e
7 changed files with 19 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
import { ContextToken } from '../context-token';
import { ContextAlias } from '../context-token';
import { UmbContextConsumer } from './context-consumer';
import { UmbContextCallback } from './context-request.event';
@@ -14,7 +14,7 @@ export class UmbContextConsumerController<T = unknown>
constructor(
host: UmbControllerHostInterface,
contextAlias: string | ContextToken<T>,
contextAlias: string | ContextAlias<T>,
callback: UmbContextCallback<T>
) {
super(host, contextAlias, callback);

View File

@@ -1,4 +1,4 @@
import { ContextToken } from '../context-token';
import { ContextAlias } from '../context-token';
import { isUmbContextProvideEventType, umbContextProvideEventType } from '../provide/context-provide.event';
import { UmbContextRequestEventImplementation, UmbContextCallback } from './context-request.event';
@@ -25,7 +25,7 @@ export class UmbContextConsumer<HostType extends EventTarget = EventTarget, T =
*/
constructor(
protected host: HostType,
protected _contextAlias: string | ContextToken,
protected _contextAlias: string | ContextAlias,
private _callback: UmbContextCallback<T>
) {}

View File

@@ -1,4 +1,4 @@
import { ContextToken } from '../context-token';
import { ContextAlias } from '../context-token';
export const umbContextRequestEventType = 'umb:context-request';
@@ -9,7 +9,7 @@ export type UmbContextCallback<T = unknown> = (instance: T) => void;
* @interface UmbContextRequestEvent
*/
export interface UmbContextRequestEvent extends Event {
readonly contextAlias: string | ContextToken;
readonly contextAlias: string | ContextAlias;
readonly callback: UmbContextCallback;
}
@@ -21,7 +21,7 @@ export interface UmbContextRequestEvent extends Event {
*/
export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent {
public constructor(
public readonly contextAlias: string | ContextToken,
public readonly contextAlias: string | ContextAlias,
public readonly callback: UmbContextCallback
) {
super(umbContextRequestEventType, { bubbles: true, composed: true, cancelable: true });

View File

@@ -1,4 +1,4 @@
export class ContextToken<T = unknown> {
export class ContextAlias<T = unknown> {
/**
* @param _desc Description for the token,
* used only for debugging purposes,
@@ -9,11 +9,11 @@ export class ContextToken<T = unknown> {
/**
* @internal
*/
get multi(): ContextToken<Array<T>> {
return this as ContextToken<Array<T>>;
get multi(): ContextAlias<Array<T>> {
return this as ContextAlias<Array<T>>;
}
toString(): string {
return `${ContextToken.name} ${this._desc}`;
return `${ContextAlias.name} ${this._desc}`;
}
}

View File

@@ -1,4 +1,4 @@
import { ContextToken } from '../context-token';
import { ContextAlias } from '../context-token';
export const umbContextProvideEventType = 'umb:context-provide';
@@ -7,7 +7,7 @@ export const umbContextProvideEventType = 'umb:context-provide';
* @interface UmbContextProvideEvent
*/
export interface UmbContextProvideEvent extends Event {
readonly contextAlias: string | ContextToken;
readonly contextAlias: string | ContextAlias;
}
/**
@@ -17,7 +17,7 @@ export interface UmbContextProvideEvent extends Event {
* @implements {UmbContextProvideEvent}
*/
export class UmbContextProvideEventImplementation extends Event implements UmbContextProvideEvent {
public constructor(public readonly contextAlias: string | ContextToken) {
public constructor(public readonly contextAlias: string | ContextAlias) {
super(umbContextProvideEventType, { bubbles: true, composed: true });
}
}

View File

@@ -1,4 +1,4 @@
import { ContextToken } from '../context-token';
import { ContextAlias } from '../context-token';
import { UmbContextProvider } from './context-provider';
import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controller';
@@ -10,7 +10,7 @@ export class UmbContextProviderController<T = unknown>
return this._contextAlias.toString();
}
constructor(host: UmbControllerHostInterface, contextAlias: string | ContextToken<T>, instance: T) {
constructor(host: UmbControllerHostInterface, contextAlias: string | ContextAlias<T>, instance: T) {
super(host, contextAlias, instance);
// TODO: What if this API is already provided with this alias? maybe handle this in the controller:

View File

@@ -1,5 +1,5 @@
import { umbContextRequestEventType, isUmbContextRequestEvent } from '../consume/context-request.event';
import { ContextToken } from '../context-token';
import { ContextAlias } from '../context-token';
import { UmbContextProvideEventImplementation } from './context-provide.event';
/**
@@ -9,7 +9,7 @@ import { UmbContextProvideEventImplementation } from './context-provide.event';
export class UmbContextProvider<HostType extends EventTarget = EventTarget> {
protected host: HostType;
protected _contextAlias: string | ContextToken;
protected _contextAlias: string | ContextAlias;
#instance: unknown;
/**
@@ -19,7 +19,7 @@ export class UmbContextProvider<HostType extends EventTarget = EventTarget> {
* @param {*} instance
* @memberof UmbContextProvider
*/
constructor(host: HostType, contextAlias: string | ContextToken, instance: unknown) {
constructor(host: HostType, contextAlias: string | ContextAlias, instance: unknown) {
this.host = host;
this._contextAlias = contextAlias;
this.#instance = instance;