Skip to content

Instantly share code, notes, and snippets.

@benjamingr
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benjamingr/749bfe2b3c0411c7430c to your computer and use it in GitHub Desktop.
Save benjamingr/749bfe2b3c0411c7430c to your computer and use it in GitHub Desktop.
function ResourceBuilder(){
this._dependencies = [];
}
ResourceBuilder.prototype.addDependency = function(dep){
this._dependencies.add(dep);
}
ResourceBuilder.protototype.get = function(){
var loadPromises = this._dependencies.map(loadDependency); // alternatively, dependencies could be promises already
return Promise.all(loadPromises).then(function(loadedResourcesArray){
// do something with obj, or return the resource
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment