From 244b99b789ec62c7fa285d444f912fa3cf2696cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 13 Dec 2022 22:10:51 +0100 Subject: [PATCH] unregistre extension method --- .../extensions-api/registry/extension.registry.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/core/extensions-api/registry/extension.registry.ts b/src/Umbraco.Web.UI.Client/src/core/extensions-api/registry/extension.registry.ts index 9a344817ef..661b92914a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/extensions-api/registry/extension.registry.ts +++ b/src/Umbraco.Web.UI.Client/src/core/extensions-api/registry/extension.registry.ts @@ -40,6 +40,19 @@ export class UmbExtensionRegistry { } } + unregister(alias:string): void { + const oldExtensionsValues = this._extensions.getValue(); + const newExtensionsValues = oldExtensionsValues.filter((extension) => extension.alias !== alias); + + // TODO: Maybe its not needed to fire an console.error. as you might want to call this method without needing to check the existence first. + if (oldExtensionsValues.length === newExtensionsValues.length) { + console.error(`Unable to unregister extension with alias ${alias}`); + return; + } + + this._extensions.next(newExtensionsValues); + } + isRegistered(alias: string): boolean { const values = this._extensions.getValue(); return values.some((ext) => ext.alias === alias);