optional destroy on context instances

This commit is contained in:
Niels Lyngsø
2023-01-25 16:25:34 +01:00
parent 1f770840d0
commit 339db3eb6f
2 changed files with 7 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ export class UmbContextProviderController<T = unknown>
}
public destroy() {
super.destroy();
if (this.host) {
this.host.removeController(this);
}

View File

@@ -53,4 +53,10 @@ export class UmbContextProvider<HostType extends EventTarget = EventTarget> {
event.stopPropagation();
event.callback(this.#instance);
};
destroy(): void {
// I want to make sure to call this, but for now it was too overwhelming to require the destroy method on context instances.
(this.#instance as any).destroy?.();
};
}