@@ -20,8 +20,8 @@ export class DynamicFlatNode {
2020
2121
2222/**
23- * Database for dynamic data. When expanding a node in the tree, the data source will need to fetch
24- * the descendants data from the database.
23+ * Database for dynamic data. When expanding a node in the tree, the data
24+ * source will need to fetch the descendants data from the database.
2525 */
2626export class DynamicDatabase {
2727 dataMap = new Map ( [
@@ -47,12 +47,11 @@ export class DynamicDatabase {
4747 return this . dataMap . has ( node ) ;
4848 }
4949}
50+
5051/**
51- * File database, it can build a tree structured Json object from string.
52- * Each node in Json object represents a file or a directory. For a file, it has filename and type.
53- * For a directory, it has filename and children (a list of files or directories).
54- * The input will be a json object string, and the output is a list of `FileNode` with nested
55- * structure.
52+ * Plant database that can build a tree-structured JSON object from a string. Each node in the
53+ * object represents a plant or a group of plants. The input will be a JSON object string, and
54+ * the output is a list of `FileNode`-s with a nested structure.
5655 */
5756@Injectable ( )
5857export class DynamicDataSource {
@@ -81,11 +80,11 @@ export class DynamicDataSource {
8180 /** Handle expand/collapse behaviors */
8281 handleTreeControl ( change : SelectionChange < DynamicFlatNode > ) {
8382 if ( change . added ) {
84- change . added . forEach ( ( node ) => this . toggleNode ( node , true ) ) ;
83+ change . added . forEach ( node => this . toggleNode ( node , true ) ) ;
8584 }
8685 if ( change . removed ) {
8786 // Use reverse to remove from bottom to top
88- change . removed . reverse ( ) . forEach ( ( node ) => this . toggleNode ( node , false ) ) ;
87+ change . removed . slice ( ) . reverse ( ) . forEach ( node => this . toggleNode ( node , false ) ) ;
8988 }
9089 }
9190
0 commit comments