1.0.46 • Published 6 years ago

node-dinjector v1.0.46

Weekly downloads
8
License
ISC
Repository
github
Last release
6 years ago

Node Dependency Injection

Installation

npm i -S node-dinjector

Including library in your project

const DInjector = require('node-dinjector');
const DInjectorStore = DInjector.Store;
const DInjectorHelper = DInjector.Helper;

Example

const DInjector = require('../DInjector');
const DInjectorStore = DInjector.Store;
const DInjectorHelper = DInjector.Helper;

const injector = new DInjector();
injector.getStore().set('a', 123); // set di

class Controller {
  test(a, b) {
    console.log(a, b);
  },
  test(c, a, b) {
    console.log(c, a, b);
  }
}
const c = new Controller();
// replace c functions with resolved functions using injector
DInjectorHelper.mapFunctions(c, func => injector.resolve(func, c));
// call test function with b parameter
c.test(5);
// call test2 function with c and b parameters
c.test2(1, 2);

Will get updated soon

1.0.46

6 years ago

1.0.45

6 years ago

1.0.44

6 years ago

1.0.43

7 years ago

1.0.42

7 years ago

1.0.41

7 years ago

1.0.4

7 years ago

1.0.31

7 years ago

1.0.22

7 years ago

1.0.3

7 years ago

1.0.21

7 years ago

1.0.11

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago