diff --git a/main/contracts/contracts.ts b/main/contracts/contracts.ts index 485a580..cca4f92 100644 --- a/main/contracts/contracts.ts +++ b/main/contracts/contracts.ts @@ -113,6 +113,13 @@ export interface IMessageBroker { * @returns An instance of the messagebroker that matches the scopeName provided */ createScope(scopeName: string): IMessageBroker; + + /** + * Returns true if this is root node of the tree of MessageBrokers. + * The root MessageBroker will not have a parent MessageBroker. + * @returns A boolean indicating whether this is the root or not + */ + isRoot(): boolean; } /** diff --git a/main/core/messagebroker.ts b/main/core/messagebroker.ts index 3550c1f..2c111ca 100644 --- a/main/core/messagebroker.ts +++ b/main/core/messagebroker.ts @@ -207,6 +207,10 @@ export class MessageBroker implements IMessageBroker { return channel != null && channel.subscription != null; } + public isRoot(): boolean { + return this._parent === undefined; + } + public get parent(): IMessageBroker | undefined { return this._parent; }