Skip to content

Commit

Permalink
added an isRoot method to the messagebroker
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanm3341 committed Nov 13, 2024
1 parent 0389a8b commit 22422cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main/contracts/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export interface IMessageBroker<T> {
* @returns An instance of the messagebroker that matches the scopeName provided
*/
createScope(scopeName: string): IMessageBroker<T>;

/**
* 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;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions main/core/messagebroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export class MessageBroker<T = any> implements IMessageBroker<T> {
return channel != null && channel.subscription != null;
}

public isRoot(): boolean {
return this._parent === undefined;
}

public get parent(): IMessageBroker<T> | undefined {
return this._parent;
}
Expand Down

0 comments on commit 22422cd

Please sign in to comment.