File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,22 @@ export class TreeController {
6767 this . treeService . fireNodeCreated ( newTree ) ;
6868 }
6969
70+ public addChildAsync ( newNode : TreeModel ) : Promise < Tree > {
71+ if ( this . tree . hasDeferredChildren ( ) && ! this . tree . childrenWereLoaded ( ) ) {
72+ return Promise . reject ( new Error ( 'This node loads its children asynchronously, hence child cannot be added this way' ) ) ;
73+ }
74+
75+ const newTree = this . tree . createNode ( Array . isArray ( newNode . children ) , newNode ) ;
76+ this . treeService . fireNodeCreated ( newTree ) ;
77+
78+ // This will give TreeInternalComponent to set up a controller for the node
79+ return new Promise ( resolve => {
80+ setTimeout ( ( ) => {
81+ resolve ( newTree ) ;
82+ } )
83+ } )
84+ }
85+
7086 public changeNodeId ( id : string | number ) {
7187 if ( ! id ) {
7288 throw Error ( 'You should supply an id!' ) ;
You can’t perform that action at this time.
0 commit comments