From dfe1460a59c0a13a8a4720b914f17aaab74eb00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 2 Jan 2023 16:10:48 +0100 Subject: [PATCH] is consumer context method --- .../src/core/context-api/consume/context-consumer.ts | 5 +++++ .../consume/is-context-consumer-type.function.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/core/context-api/consume/is-context-consumer-type.function.ts diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index 45ace142f1..e8c3cb8919 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -6,6 +6,11 @@ import { UmbContextRequestEventImplementation, UmbContextCallback } from './cont * @class UmbContextConsumer */ export class UmbContextConsumer { + + get consumerAlias() { + return this._contextAlias; + } + /** * Creates an instance of UmbContextConsumer. * @param {EventTarget} target diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/is-context-consumer-type.function.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/is-context-consumer-type.function.ts new file mode 100644 index 0000000000..f6339ee4f6 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/is-context-consumer-type.function.ts @@ -0,0 +1,7 @@ +import { UmbContextConsumer } from './context-consumer'; + +export function isContextConsumerType(instance: unknown): instance is UmbContextConsumer { + return ( + typeof instance === 'object' && instance !== null && (instance as UmbContextConsumer).consumerAlias !== undefined + ); +}