improved javascript dependency injection framework
JavaScript dependency injection is all the rage these days. But after looking through all the options, I just haven’t found the perfect framework. That’s why I’m introducing my own framework to provide the best possible interface, helping you to inject exactly the dependency you need.
First, I want to introduce the problem we’re trying to solve. Let’s say you have a JavaScript function that has a dependency, but the client knows too much about the dependency. This is what smarty-pants engineers call “tight coupling”:
function Dependency1(say){
alert(say);
}
function Client(){
new Dependency1('hi'); // bad! tightly coupled interface
}
new Client();