Skip to content

Instantly share code, notes, and snippets.

@mcfedr
mcfedr / cbcontrol.js
Created August 13, 2012 19:39
callback control - simple way to deal with situations when you have lots of callbacks that need to come back together
/**
* count is how many callbacks there are in total
* after to the function to call when all your callbacks have completed
* return a function that you should call to create your callbacks,
* optionally passing an individual callback handler
*/
function cbcontrol(count, after) {
return function(cb) {
return function() {
cb && cb.apply(this, arguments);