Events

loading

Fired when tree.load() is called.

tree.on('loading', () => {
  // Do something
});

beforeFirstDraw

Fired after tree.load() has been called, but before the tree is drawn for the first time.

tree.on('beforeFirstDraw', () => {
  // Do setup that could not be added by config. Branches and leaves are now available.
});

loaded

Fired when a tree has successfuly loaded and drawn for the first time.

tree.on('loaded', () => {
  // Respond to fully-loaded tree.
});

error

Fired when a tree has failed to load.

tree.on('error', ({ error }) => {
  console.log(error);
});

subtree

Fired when a subtree is drawn, supplying the new root node.

tree.on('subtree', ({ node }) => {
  console.log(node.id);
});

updated

Fired when the user clicks on the tree, or via tree.updateLeaves().

tree.on('updated', ({ property, nodeIds }) => {
  if (property === 'selected') {
    console.log(nodeIds);
  }
});