internal-command-queue
v0.0.3
Published
Simple command queue which doesn't require any external service.
Downloads
2
Readme
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.
});