CommandObject
Class which wraps a command handler with additional useful data.
Static Method Summary
Static Private Methods | ||
private static |
generateHandler(handler: Function, middleware: middlewareLayer[]): Function Applies middleware to a command handler and returns the resulting handler function. |
Constructor Summary
Public Constructor | ||
public |
constructor(configuration: CommandConfiguration) Constructor. |
Member Summary
Public Members | ||
public |
An array of aliases for the command. |
|
public |
dependencies: StringMap A mapping between service names and the context names they should be injected under for the command handler. |
|
public |
The description for the command. |
|
public |
The name of the group this command is part of, if any. |
|
public |
The main trigger of the command, also acting as its name. |
|
public |
An array of parameter definitions for the command. |
Private Members | ||
private |
The command handler function with middleware applied to it. |
|
private |
middleware: middlewareLayer[] The middleware applied to the handler function. |
|
private |
The original command handler function. |
Method Summary
Public Methods | ||
public |
Executes the command handler. |
|
public |
linkGroup(commandGroup: CommandGroup) Subscribes to updates from a command group. |
Static Private Methods
private static generateHandler(handler: Function, middleware: middlewareLayer[]): Function source
Applies middleware to a command handler and returns the resulting handler function.
Params:
Name | Type | Attribute | Description |
handler | Function | The command handler. |
|
middleware | middlewareLayer[] | The middleware to apply. |
Public Constructors
public constructor(configuration: CommandConfiguration) source
Constructor.
Params:
Name | Type | Attribute | Description |
configuration | CommandConfiguration | The command configuration. |
Throw:
Thrown if the given configuration is not a plain object. |
Public Members
public dependencies: StringMap source
A mapping between service names and the context names they should be injected under for the command handler.
Private Members
Public Methods
public handle(context: Object): Promise<Object> source
Executes the command handler.
Params:
Name | Type | Attribute | Description |
context | Object | The command context. |
public linkGroup(commandGroup: CommandGroup) source
Subscribes to updates from a command group.
Params:
Name | Type | Attribute | Description |
commandGroup | CommandGroup | The command group. |