method-cxt-di
v0.0.3
Published
npm install method-cxt-di --save
Downloads
5
Readme
install
npm install method-cxt-di --save
example
let di = require("method-cxt-di");
let obj = {
name: "leo",
changename(n) {
this.name = n;
// this.service need DI
this.service.log();
}
}
let service = {
log() {
console.log("method\'s name iss " + this.method);
}
}
function dataDIProvider(method, cxt, args, methodname) {
return {
service: Object.assign({ method: methodname }, service)
};
}
let obj2 = di(obj, dataDIProvider);
obj2.changename("leo"); // method's name is changename
LICENSE
apache 2.0