1.1.1 • Published 8 years ago

nan-ioc v1.1.1

Weekly downloads
-
License
Apache-2.0
Repository
gitlab
Last release
8 years ago

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());
1.1.1

8 years ago

1.1.0

8 years ago