Skip to content

Instantly share code, notes, and snippets.

@kenperkins
Last active August 29, 2015 14:06
Show Gist options
  • Save kenperkins/2d93ff7b7cb2889faf97 to your computer and use it in GitHub Desktop.
Save kenperkins/2d93ff7b7cb2889faf97 to your computer and use it in GitHub Desktop.
var async = require('async');
var data;
MakeUsesrHttpCall(function(err,res){
data.users = res;
});
MakeTestHttpCall(function(err,res){
data.tests = res;
});
exports.init = function(callback) {
// you could eager return if the data is present,
// or perhaps via a supplied optional first argument
if (data) {
callback(null, data);
return;
}
data = {};
async.parallel([ MakeUsesrHttpCall, MakeTestsHttpCall ], function(err) {
callback(err, data);
});
});
var a = requre('a.js');
a.init(function(err, data) {
// do something with data here
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment