* 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)
| 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 |
no test coverage detected