Skip to content

Instantly share code, notes, and snippets.

@nanlabsweb
Last active June 1, 2017 18:40
Show Gist options
  • Save nanlabsweb/08f65d4d2edce9643b235cb1c7528bd6 to your computer and use it in GitHub Desktop.
Save nanlabsweb/08f65d4d2edce9643b235cb1c7528bd6 to your computer and use it in GitHub Desktop.
const ioc = require('nan-ioc');
class B {
sayHello () {
return `When call to aService he says ${this.a.sayHello()}`;
}
}
const config = {
user: { name: 'John Smith' }
};
ioc
.module(['./foo'])
.component('bService', {
'class': B,
'a': ioc.ref('aService'),
'userName': '${user.name}'
})
.build(config);
const b = ioc.get('bService');
console.log(b.sayHello());
/*
Note: This code is used for explaining the features of our lib. Add the next to get this code
working:
#foo/index.js
const ioc = require('nan-ioc');
class A {
sayHello () {
return 'Hello!!';
}
}
module.exports = ioc
.module()
.component('aService', {
'class': A
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment