(private) new Instruction(name, payloadopt, argsopt)
Create a new instruction to be executed later
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String | name of the instruction. this is useful for later lookup of the |
|
payload |
Object |
<optional> |
a JSON compatible object that will be forwarded as the 2nd last parameter to the processor. |
args |
Array |
<optional> |
all the arguments that needs to be passed to the processor is in this array |
- Source:
Example
var inst = Instruction.create(function (arg1, payload, next) {
console.log(payload);
next(null, 'hello-on-execute with ' + arg1);
}, 'sample-instruction', {
payloadData1: 'value'
}, ['one-arg']);
// now, when we do execute, the result will be a console.log of payload and message will be as expected
instance.execute(function (err, message) {
console.log(message);
});
Members
(static) _queue :Array
Store all thenable items
Type:
- Array
- Source:
Methods
(static) create(processor, name, payloadopt, argsopt) → {Instruction}
Shortcut to new Instruction(...);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
processor |
function | ||
name |
String | ||
payload |
Object |
<optional> |
|
args |
Array |
<optional> |
- Source:
Returns:
- Type
- Instruction
execute(callback, scopeopt)
Executes an instruction with previously saved payload and arguments
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function | ||
scope |
* |
<optional> |
- Source: