Created
November 25, 2014 18:09
-
-
Save matthewp/178e8cd2b699bff0e865 to your computer and use it in GitHub Desktop.
meta deps extension
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
var instantiate = loader.instantiate; | |
loader.instantiate = function(load){ | |
var loader = this; | |
var meta = loader.meta[load.name]; | |
var deps = (meta && meta.deps) || []; | |
if(deps.length) { | |
var promises = []; | |
for(var i = 0, len = deps.length; i < len; i++) { | |
promises.push(loader.import(deps[i])); | |
} | |
return Promise.all(promises).then(function(){ | |
return instantiate.call(loader, load); | |
}); | |
} | |
return instantiate.call(loader, load); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment