CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)
https://angular2-tree.readme.io/docs
MIT License
1.09k stars 488 forks source link

Asynchronous execution in doForAll is unexpected #928

Open sechel opened 2 years ago

sechel commented 2 years ago

I try to execute a function for all nodes in the tree and tried using the doForAll tree model function. I was surprised to learn that the corresponding method on the nodes is executed asynchronously:

  doForAll(fn: (node: ITreeNode) => any) {
    Promise.resolve(fn(this)).then(() => {
      if (this.children) {
        this.children.forEach((child) => child.doForAll(fn));
      }
    });
  }

That comes unexpected and is IMO undocumented and may be a bug.