3 ms·
var prod_dependencies = { obj0: require('obj0'), obj1: require('obj1') }; var test_dependencies = { obj0: require('mockobj0'), obj1: requir
by kuni-toko-tachi 12y ago
var prod_dependencies = {
obj0: require('obj0'),
obj1: require('obj1')
};
var test_dependencies = {
obj0: require('mockobj0'),
obj1: require('mockobj1')
};
var dependencies = test_dependencies;
some_func(dependencies.obj0,dependencies.obj1);
Javascript does not need Java-style dependency injection.
Javascript's configuration language JSON is valid Javascript.
- nilliams 12y agoYou're slightly off on your definitions - what you show in that example is dependency injection. You are injecting dependencies into `some_func` by passing them in. See my response to kyllo below. I think what you are arguing against is using further patterns to facilitate dependency injection, e.g. IOC containers, or what Angular uses (service locators).
- luikore 12y agoNot all JSON are valid javascript: http://timelessrepo.com/json-isnt-a-javascript-subset http://timelessrepo.com/json-isnt-a-javascript-subset