Last active
August 29, 2015 14:01
-
-
Save benjamingr/749bfe2b3c0411c7430c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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