ajector

Asynchronous dependency injector

ajector

Asynchronous dependency injector.

npm install ajector

  1. Write modules

    // services/Service1.js 
    module.exports = function () {
      return {};
    };
  2. Setup injector

    var ajector = require('ajector');
     
    var injector = ajector(__dirname + '/services');
    injector.instance('config', config);
    injector.instance('db', db);
  3. Use injector

    injector.inject(function (Service1dbconfig) {
      // this function will be called asynchronously after all required modules are initialized 
    });

For more details take a look at provided testsuite. There are all possible use cases.