nan-ioc

1.1.1 • Public • Published

IoC

Lightweight IoC container.

Code sample

var ioc = require('nan-ioc');

var config = {
  user: {name: 'John Smith'}
};


function B() {
}

B.prototype.sayHello = function () {
  return "When call to aService he says '" + this.a.sayHello() + "'";
};

function C() {
}

C.prototype.sayHello = function () {
  return "When call to aService he says '" + this.a.sayHello() + "'. When call to bService he says '" + this.b.sayHello();
};


ioc.module(['./foo'])
  .component('bService', {
    'class': B,
    'a': ioc.ref('aService')
  })
  .component('cService', {
    'class': C,
    'a': ioc.ref('aService'),
    'b': ioc.ref('bService')
  })
  .build(config);


var c = ioc.get('cService');
console.log(c.sayHello());

Package Sidebar

Install

npm i nan-ioc

Weekly Downloads

2

Version

1.1.1

License

Apache-2.0

Last publish

Collaborators

  • ulises-jeremias
  • nanlabs1