Skip to content

Instantly share code, notes, and snippets.

@jasonwaters
Created February 14, 2017 22:27
Show Gist options
  • Save jasonwaters/56f473f7166bab1f37baf2f2beab3eb4 to your computer and use it in GitHub Desktop.
Save jasonwaters/56f473f7166bab1f37baf2f2beab3eb4 to your computer and use it in GitHub Desktop.
simple dependency injection
function randy() {
return Math.random();
}
function smoke() {
return "poof";
}
function depend(dependencies, fn) {
fn.apply(null, dependencies.map(dep => window[dep]));
}
depend(['randy', 'smoke'], function(rrr, sss) {
console.log(sss(), rrr());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment