method-cxt-di

0.0.3 • Public • Published

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    

Readme

Keywords

none

Package Sidebar

Install

npm i method-cxt-di

Weekly Downloads

1

Version

0.0.3

License

ISC

Last publish

Collaborators

  • leogiese