IOC
This is the third rewrite of my really old js IOC container: http://mykenta.blogspot.it/2007/09/kentaioc-js-ioc-library.html.
How to use
To directly use the IOC container with manual injection:
// Construction injection example ;;;; const container = ;container; const warrior1 = container;const warrior2 = container; warrior1 // Pierced The evildoers armorwarrior2 // Chopped The evildoers in half
// Setter injection example;;;; const container = ;container; const warrior1 = container;const warrior2 = container; warrior1 // Pierced The evildoers armorwarrior2 // Chopped The evildoers in half
Alternatively it's possible to get a Ninject style configuration using Unit:
; ;; // This is the contract. { throw 'not implemented'; } { return `Pierced armor`; } { return `Chopped in half`; } const unit1 = ;const unit2 = ; // This is where the class defines its contract. static weapon = IWeapon; { return thisweapon; } // In unit 1 we will configure IWeapon to be Sword instance...unit1;// ...while in unit 2 it will be Shuriken.unit2; unit1; // Chopped The evildoers in halfunit2; // Pierced The evildoers armor