Created
February 14, 2017 22:27
-
-
Save jasonwaters/56f473f7166bab1f37baf2f2beab3eb4 to your computer and use it in GitHub Desktop.
simple dependency injection
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 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