Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple utility to allow callbacks to stack up until the drain has been unplugged.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.jshintrc
.jshintrc-test
README.md
package.json

README.md

callback-pool

Simple utility to queue callbacks in a pool until the drain has been unplugged.

npm install callback-pool --save

Example

var pool = require('callback-pool');
var myPool = pool.create();//creates a new pool

//these are queued up
myPool.add(function(a, b){console.log('foo');});
myPool.add(function(a, b){console.log('boo');});

myPool.drain(1,2);//all callbacks are executed asynchronously with 1 and 2.

//these are now asynchronously executed immediately with 1 and 2
myPool.add(function(a, b){console.log('execute me');});
myPool.add(function(a, b){console.log('me too');});

myPool.plug();//allows you to start over.
Something went wrong with that request. Please try again.