MCPcopy Index your code
hub / github.com/angular/components / _getDirectChildren

Method _getDirectChildren

src/cdk/tree/tree.ts:744–780  ·  view source on GitHub ↗

* Gets the direct children of a node; used for compatibility between the old tree and the * new tree.

(dataNode: T)

Source from the content-addressed store, hash-verified

742 * new tree.
743 */
744 _getDirectChildren(dataNode: T): Observable<T[]> {
745 const levelAccessor = this._getLevelAccessor();
746 const expansionModel = this._expansionModel ?? this.treeControl?.expansionModel;
747 if (!expansionModel) {
748 return observableOf([]);
749 }
750
751 const key = this._getExpansionKey(dataNode);
752
753 const isExpanded = expansionModel.changed.pipe(
754 switchMap(changes => {
755 if (changes.added.includes(key)) {
756 return observableOf(true);
757 } else if (changes.removed.includes(key)) {
758 return observableOf(false);
759 }
760 return EMPTY;
761 }),
762 startWith(this.isExpanded(dataNode)),
763 );
764
765 if (levelAccessor) {
766 return combineLatest([isExpanded, this._flattenedNodes]).pipe(
767 map(([expanded, flattenedNodes]) => {
768 if (!expanded) {
769 return [];
770 }
771 return this._findChildrenByLevel(levelAccessor, flattenedNodes, dataNode, 1);
772 }),
773 );
774 }
775 const childrenAccessor = this._getChildrenAccessor();
776 if (childrenAccessor) {
777 return coerceObservable(childrenAccessor(dataNode) ?? []);
778 }
779 throw getTreeControlMissingError();
780 }
781
782 /**
783 * Given the list of flattened nodes, the level accessor, and the level range within

Callers 2

_getNodeChildrenMethod · 0.95
ngAfterContentInitMethod · 0.80

Calls 7

_getLevelAccessorMethod · 0.95
_getExpansionKeyMethod · 0.95
isExpandedMethod · 0.95
_findChildrenByLevelMethod · 0.95
_getChildrenAccessorMethod · 0.95
coerceObservableFunction · 0.90

Tested by

no test coverage detected