Description
What is the expected behavior?
When the children of a NestedTreeNode
are an observable, CdkTree should not subscribe to the observable until it actually needs to display the child nodes, e.g. when the user has clicked to expand the node.
Imagine if resolving the children of a given node required an API call. If the CdkTree eagerly fetched the children of every visible node, expanding a node with 100 children would launch 100 simultaneous API requests to the API.
What is the current behavior?
CdkTree eagerly fetches the children of every visible node, so expanding a node with 100 children will launch 100 simultaneous API requests to the API.
What are the steps to reproduce?
https://stackblitz.com/edit/angular-eyf6xl
Check the console to see when subscriptions to the children observables are made. You will see that the children for each node are loaded as soon as their parent node is visible, and before the parent node is expanded.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 7
Material: 7
OS: macOS
TypeScript: 3.3