Skip to content

seriousManual/eventedQueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eventedQueue Build Status

NPM

NPM

The eventedQueue collects jobs in the form of callbacks supplied with an arbitrary number of arguments. When the queue is triggered, the jobs will be executed.

Installation

$ npm install eventedqueue

Example

var EventedQueue = require('eventedqueue');

var myQueue = EventedQueue();

var job = function(name) {
    console.log('job "' + name + '" executed');
};

myQueue.push(job, 'foo');
myQueue.push(job, 'bar');
myQueue.push(job, 'bax');

setTimeout(function() {
    myQueue.trigger();
}, 1000);

/*
output:

job "foo" executed
job "bar" executed
job "bax" executed
*/

Invocation

Constructor([autoRelock])

Creates a new eventedQueue that accepts jobs and can be triggered to execute these jobs.

The optional parameter autoRelock specifies if the queue should trigger jobs, that are subsequently pushed after the queue has been triggered, automatically. default: false

EventedQueue.push(jobFunction, [arg1, arg2, ...])

Adds a new job to the eventedQueue. An arbitrary number of parameters can be supplied and are optional.

EventedQueue.trigger()

Triggers the queue and causes all enqueued jobs to be executed.

EventedQueue.relock()

If autoRelock is set to false via the relock command the queue can be set to enque jobs again.

EventedQueue.size()

Returns the number of enqueued jobs.

EventedQueue.empty

An optional callback that is called when the queue is emptied.

About

collector for jobs that depend on an external event

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published