Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/libs/controller/controller.class.ts

28 lines
650 B
TypeScript
Raw Normal View History

2023-01-03 08:47:28 +01:00
import { UmbControllerHostInterface } from './controller-host.mixin';
import { UmbControllerInterface } from './controller.interface';
2023-01-02 13:27:35 +01:00
2023-01-02 14:47:46 +01:00
export abstract class UmbController implements UmbControllerInterface {
2023-01-03 12:03:34 +01:00
protected host?: UmbControllerHostInterface;
2023-01-02 13:27:35 +01:00
private _alias?: string;
public get unique() {
2023-01-17 11:25:58 +01:00
return this._alias;
}
constructor(host: UmbControllerHostInterface, alias?: string) {
2023-01-03 12:03:34 +01:00
this.host = host;
this._alias = alias;
2023-01-03 12:03:34 +01:00
this.host.addController(this);
2023-01-03 08:47:28 +01:00
}
2023-01-02 13:27:35 +01:00
2023-01-03 08:47:28 +01:00
abstract hostConnected(): void;
abstract hostDisconnected(): void;
2023-01-02 13:27:35 +01:00
2023-01-03 08:47:28 +01:00
public destroy() {
2023-01-03 12:03:34 +01:00
if (this.host) {
this.host.removeController(this);
2023-01-03 08:47:28 +01:00
}
2023-01-03 12:03:34 +01:00
delete this.host;
2023-01-03 08:47:28 +01:00
}
}