remove event listener

This commit is contained in:
Niels Lyngsø
2024-11-05 16:25:42 +01:00
parent 3653d61713
commit 171ea8422d

View File

@@ -103,6 +103,8 @@ export class UmbContextProvider<BaseType = unknown, ResultType extends BaseType
destroy(): void {
this.hostDisconnected();
// Note we are not removing the event listener in the hostDisconnected, therefor we do it here [NL].
this.#eventTarget?.removeEventListener(UMB_CONTENT_REQUEST_EVENT_TYPE, this.#handleContextRequest);
// We want to call a destroy method on the instance, if it has one.
(this.#instance as any)?.destroy?.();
this.#instance = undefined;