0.0.3 • Published 9 years ago

internal-command-queue v0.0.3

Weekly downloads
10
License
-
Repository
github
Last release
9 years ago

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.
});