CommandMiddleware
Executes command trees using registered middleware.
Middleware are functions that take two arguments: commandObject, context
Where commandObject may have multiple keys, and middleware may handle none or more of those keys.
eg. the run
middleware handles only the command key run
Constructor Summary
Public Constructor | ||
public |
constructor(middlewares: *[]) |
Member Summary
Public Members | ||
public |
middlewares: * |
Method Summary
Public Methods | ||
public |
Each middleware is called with each command in a flattened depth-first stack. |
|
public |
use(middlewares: *) |
Public Constructors
public constructor(middlewares: *[]) source
Params:
Name | Type | Attribute | Description |
middlewares | *[] |
|
Public Members
public middlewares: * source
Public Methods
public call(commandRoot: Object, actionName: String, updateContext: Function): Promise source
Each middleware is called with each command in a flattened depth-first stack.
Any command that returns a Promise will be resolved, and the entire action (add, remove, update) is considered complete when all command results have resolved.
Params:
Name | Type | Attribute | Description |
commandRoot | Object | The root command node of the tree as collected by DryadTree collectCommands. It contains pointers to the children. |
|
actionName | String | Each node has its context updated after success or failure as |
|
updateContext | Function | supplied by the DryadPlayer, a function to update the context for a node. |
public use(middlewares: *) source
Params:
Name | Type | Attribute | Description |
middlewares | * |