internal-command-queue

0.0.3 • Public • Published

NPM Version Build Status Coverage Status

Command

What commands will do is up to you! But, first, they'll need a name...

var Command = require("internal-command-queue").Command;
 
var command = new Command("welcome");
command.implementation = function execute(parameters, callback) {
    // Here, `this` is the execution context, and provides:
    // - current command,
    // - execution occurrence,
    // - parameters
 
    callback(null, "Hello!");
};

Command Queue

Command queues have not much on their shoulders so far: they just trigger the "commandPushed" & "commandRemoved" events when commands are pushed into or removed from them.

var queue = new CommandQueue();
 
queue.when("commandPushed", function(command) {
    // Well... do something, please! For example:
    command.execute(function(error, results) {
        queue.remove(command);
    });
});
 
queue.when("commandRemoved", function() {
    // There you could do something as well.
});

Dependents (0)

Package Sidebar

Install

npm i internal-command-queue

Weekly Downloads

0

Version

0.0.3

License

none

Last publish

Collaborators

  • pvoisin