Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/libs/context-api/consume/context-consumer.controller.ts
2023-03-23 10:46:47 +01:00

30 lines
795 B
TypeScript

import { UmbContextToken } from '../token/context-token';
import { UmbContextConsumer } from './context-consumer';
import { UmbContextCallback } from './context-request.event';
import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/backoffice/controller';
export class UmbContextConsumerController<T = unknown>
extends UmbContextConsumer<UmbControllerHostInterface, T>
implements UmbControllerInterface
{
public get unique() {
return undefined;
}
constructor(
host: UmbControllerHostInterface,
contextAlias: string | UmbContextToken<T>,
callback: UmbContextCallback<T>
) {
super(host, contextAlias, callback);
host.addController(this);
}
public destroy() {
super.destroy();
if (this.host) {
this.host.removeController(this);
}
}
}