I am dealing with a tree structure that has Node objects:
class Node implements ITreeNode {
id?: any;
name: string;
children:? Node[],
enabledState = new Subject<boolean>();
toggle() {
this.enabled = !this.enabled;
this.enabledState.next(this.enabled);
}
}
I am trying to figure out how to keep track of the number of nodes that are enabled (selected). With each selection, I update the state. However, I am unsure of the best approach to counting all enabled nodes in the tree without subscribing to each individual node.