ContainerJS
ContainerJS is a Light weight Dependency Injection Contaier for JavaScript, supports AOP (aspect oriented programming).
Features:
- Basic DIContainer features, like Instance Management( Simgleton or Prototype..), Property Injection, Initialize Method ...
- Component Definition using JavaScript API or Annotations, Not XML.
- supports AOP (aspect oriented programming)
Usage
<script type="text/javascript" src="../container.js" ></script>
var stdout = document.getElementById( "stdout" );
// class
function Kitten() {}
Kitten.prototype = {
getName: function () { return this.name; }
};
// create container.
var c = new container.Container( function( binder ) {
// bind component "mii" to a kittten class,
// and inject "mii" to a name property of component "mii".
binder.bind( Kitten ).to( "mii" ).inject( { "name": "mii" } );
});
// getting component "mii" from container.
var mii = c.get( "mii" );
stdout.innerHTML += mii.getName(); // mii