From 225070462235703d767605376d39cde015b51bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 2 Jan 2023 21:33:18 +0100 Subject: [PATCH] simpler reconization of contexts recieved --- .../src/core/element/element.mixin.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts index ff94fb33e3..e7841a750f 100644 --- a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts +++ b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts @@ -61,13 +61,15 @@ export const UmbElementMixin = (superClass: T) * @memberof UmbElementMixin */ consumeAllContexts(_contextAliases: Array, callback: (_instances: ResolvedContexts) => void) { - _contextAliases.forEach((alias) => + let resolvedAmount = 0; + const controllers = _contextAliases.map((alias) => new UmbContextConsumerController(this, alias, () => { - const allResolved = this.getControllers((ctrl: UmbControllerInterface):boolean => isContextConsumerType(ctrl) && _contextAliases.indexOf(ctrl.consumerAlias) !== -1 ); + resolvedAmount++; + //const allResolved = this.getControllers((ctrl: UmbControllerInterface):boolean => isContextConsumerType(ctrl) && _contextAliases.indexOf(ctrl.consumerAlias) !== -1 ); - if (allResolved.length === _contextAliases.length) { - callback(allResolved); + if (resolvedAmount === _contextAliases.length) { + callback(controllers); } }) );