callback_tracker

Easily create callbacks that are not resolved until other callbacks have completed.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
callback_tracker
0.1.08 years ago9 years agoMinified + gzip package size for callback_tracker in KB

Readme

Callback Tracker

Sometimes you need to perform multiple operations before resolving an initial callback. This tool is a small and simple way to track all the callbacks.
example:
var tracker = require('callback_tracker');

function getOneThing(thingWanted, done) {
  //...

  // done(result);
}

function getAlotOfThings(thingsWanted, done) {
  var results = [];
  var track = tracker.create('done', function() {
    done(results);
  };

  thingsWanted.foreach(function(thingWanted) {
    getOneThing(thingWanted, track('getting ' + thingWanted, function(result) {
      results.push(result);
    }));
  });
}