Forked from benjamingr/gist:749bfe2b3c0411c7430c
Last active
August 29, 2015 14:01
-
-
Save domenic/f19ba7fb48d53e2590fa to your computer and use it in GitHub Desktop.
This file contains 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._dependencyPromises = []; | |
} | |
ResourceBuilder.prototype._load = function () { | |
// specific to the resource... | |
}; | |
ResourceBuilder.prototype.addDependency = function(dep){ | |
this._dependencyPromises.add(dep); | |
} | |
ResourceBuilder.protototype.get = function(){ | |
return Promise.all([this._load()].concat(this._dependencyPromises)).then(function(){ | |
// both the resource and its dependencies are now loaded | |
// this was done in parallel. | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment