Home Reference Source
import DryadTree from 'dryadic/src/DryadTree.js'
public class | source

DryadTree

Manages the tree structure, contexts for nodes, utilities to walk the tree, collect commands and call command middleware.

Constructor Summary

Public Constructor
public

constructor(rootDryad: Dryad, getClass: Function)

Member Summary

Public Members
public
public

dryads: *

public
public

root: *

public
public

tree: *

Method Summary

Public Methods
public

collectCommands(methodName: String, node: Dryad): Object

Collect a tree of command objects from each node for a given method.

public

Get a representation of current state of the tree.

public

makeCommandTree(nodeId: *, command: *): *

Construct a command tree for a single commandObject to be executed with a single node's context.

This is for runtime execution of commands, called from streams and async processes initiated during Dryad's .add()

public

updateContext(dryadId: String, update: Object): *

Update the context for a node.

public

walk(fn: Function, node: Object, memo: Object): *

Depth first traversal of the Dryad tree

Public Constructors

public constructor(rootDryad: Dryad, getClass: Function) source

Params:

NameTypeAttributeDescription
rootDryad Dryad
getClass Function

lookup function

Public Members

public contexts: * source

public dryads: * source

public getClass: * source

public root: * source

public rootContext: * source

public tree: * source

Public Methods

public collectCommands(methodName: String, node: Dryad): Object source

Collect a tree of command objects from each node for a given method. eg. 'add' 'remove' 'prepareForAdd'

Params:

NameTypeAttributeDescription
methodName String
node Dryad

Return:

Object

public getDebugState(): * source

Get a representation of current state of the tree. Contains add|remove|prepared and may hold errors.

Return:

*

public makeCommandTree(nodeId: *, command: *): * source

Construct a command tree for a single commandObject to be executed with a single node's context.

This is for runtime execution of commands, called from streams and async processes initiated during Dryad's .add()

Params:

NameTypeAttributeDescription
nodeId *
command *

Return:

*

public updateContext(dryadId: String, update: Object): * source

Update the context for a node.

Params:

NameTypeAttributeDescription
dryadId String
update Object

Return:

*

public walk(fn: Function, node: Object, memo: Object): * source

Depth first traversal of the Dryad tree

The function is given arguments: node {id type children} Dryad context memo

Params:

NameTypeAttributeDescription
fn Function

called with (dryad, context, node)

node Object

data object

memo Object

for usage during recursion

Return:

*