rename UmbContextAlias to UmbContextToken

This commit is contained in:
Jacob Overgaard
2023-01-19 11:01:41 +01:00
parent 86be1a37d1
commit af02bdf542
5 changed files with 8 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ export class UmbWorkspaceViewDocumentTypeDesignElement extends UmbLitElement {
constructor() {
super();
// TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextAlias
// TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextToken
this.consumeContext<UmbWorkspaceDocumentTypeContext>('umbWorkspaceContext', (documentTypeContext) => {
this._workspaceContext = documentTypeContext;
this._observeDocumentType();

View File

@@ -50,7 +50,7 @@ export class UmbDataTypeWorkspaceViewEditElement extends UmbLitElement {
this._modalService = _instance;
});
// TODO: Figure out if this is the best way to consume a context or if it could be strongly typed using UmbContextAlias
// TODO: Figure out if this is the best way to consume a context or if it could be strongly typed using UmbContextToken
this.consumeContext<UmbWorkspaceDataTypeContext>('umbWorkspaceContext', (_instance) => {
this._workspaceContext = _instance;
this._observeDataType();

View File

@@ -18,7 +18,7 @@ export class UmbWorkspaceViewDataTypeInfoElement extends UmbLitElement {
constructor() {
super();
// TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextAlias
// TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextToken
this.consumeContext<UmbWorkspaceDataTypeContext>('umbWorkspaceContext', (dataTypeContext) => {
this._workspaceContext = dataTypeContext;
this._observeDataType();

View File

@@ -69,7 +69,7 @@ export const UmbElementMixin = <T extends HTMLElementConstructor>(superClass: T)
* @param {string} aliases
* @param {method} callback Callback method called when all contexts are resolved.
* @memberof UmbElementMixin
* @deprecated it should not be necessary to consume multiple contexts at once, use consumeContext instead with an UmbContextAlias
* @deprecated it should not be necessary to consume multiple contexts at once, use consumeContext instead with an UmbContextToken
*/
consumeAllContexts(_contextAliases: Array<string>, callback: (_instances: ResolvedContexts) => void) {
let resolvedAmount = 0;

View File

@@ -13,9 +13,9 @@ The methods are (_note this can be out of date, we need to look into how we can
```
observe<T>(source: Observable<T>, callback: (_value: T) => void, unique?: string): UmbObserverController<T>
provideContext<R = unknown>(alias: string | UmbContextAlias<R>, instance: R): UmbContextProviderController<R>
provideContext<R = unknown>(alias: string | UmbContextToken<R>, instance: R): UmbContextProviderController<R>
consumeContext<R = unknown>(alias: string | UmbContextAlias<R>, callback: UmbContextCallback<R>): UmbContextConsumerController<R>
consumeContext<R = unknown>(alias: string | UmbContextToken<R>, callback: UmbContextCallback<R>): UmbContextConsumerController<R>
```
Use these for an smooth consumption, like this request for a Context API using a simple string context, where the callback value is unknown
@@ -27,10 +27,10 @@ this.consumeContext('requestThisContextAlias', (context) => {
});
```
Or use the UmbContextAlias type to define the type of the context, like this
Or use the UmbContextToken type to define the type of the context, like this
```
const contextAlias = new UmbContextAlias<SomeType>('description of context for debugging purposes');
const contextAlias = new UmbContextToken<SomeType>('description of context for debugging purposes');
this.consumeContext(contextAlias, (context) => {
// Notice this is a subscription, as context might change or a new one appears, but the value is strongly typed