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

Method _getAllChildrenRecursively

src/cdk/tree/tree.ts:934–951  ·  view source on GitHub ↗

* Gets all children and sub-children of the provided node. * * This will emit multiple times, in the order that the children will appear * in the tree, and can be combined with a `reduce` operator.

(dataNode: T)

Source from the content-addressed store, hash-verified

932 * in the tree, and can be combined with a `reduce` operator.
933 */
934 private _getAllChildrenRecursively(dataNode: T): Observable<T[]> {
935 if (!this.childrenAccessor) {
936 return observableOf([]);
937 }
938
939 return coerceObservable(this.childrenAccessor(dataNode)).pipe(
940 take(1),
941 switchMap(children => {
942 // Here, we cache the parents of a particular child so that we can compute the levels.
943 for (const child of children) {
944 this._parents.set(this._getExpansionKey(child), dataNode);
945 }
946 return observableOf(...children).pipe(
947 concatMap(child => concat(observableOf([child]), this._getAllChildrenRecursively(child))),
948 );
949 }),
950 );
951 }
952
953 private _getExpansionKey(dataNode: T): K {
954 // In the case that a key accessor function was not provided by the

Callers 1

_getDescendantsMethod · 0.95

Calls 3

_getExpansionKeyMethod · 0.95
coerceObservableFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected