1.0.0 • Published 9 years ago

callback-collector v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

callback-collector

When I was first getting acquainted with node.js, I was experimenting with different ideas for handling async callbacks. This is one of the ideas I had where you wrap each of your callbacks in a call to callback-collector. callback-collector intercepts each callback and counts the number of still pending callbacks.

Ultimately it is not what I settled on for general use; I do not recall exactly why. But, here it is for good measure anyway.

install

npm install callback-collector

example

var request = require('request');
var cbc = require('callback-collector');

var c = cbc(function () {
	console.log('0. all callbacks have been called');
});

setTimeout(c(function () {
	console.log('1. setTimeout is done');
}), 1000);

request('https://www.google.com', c(function (err, res, data) {
	console.log('2. https request is finished');
}));

output:

2. https request is finished
1. setTimeout is done
0. all callbacks have been called

license

MIT

1.0.0

9 years ago