Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-callback-collector
An async utility to collect callbacks and then execute another when all have been called
https://github.com/wankdanker/node-callback-collector
Last synced: 14 days ago
JSON representation
An async utility to collect callbacks and then execute another when all have been called
- Host: GitHub
- URL: https://github.com/wankdanker/node-callback-collector
- Owner: wankdanker
- Created: 2015-10-05T20:41:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-05T20:49:58.000Z (over 9 years ago)
- Last Synced: 2024-12-16T07:38:06.959Z (22 days ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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
-------```bash
npm install callback-collector
```example
-------```js
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:```bash
2. https request is finished
1. setTimeout is done
0. all callbacks have been called
```license
-------MIT