async-didi
Async Dependency Injection for JavaScript
Last updated 10 months ago by nikku .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install async-didi 
SYNC missed versions from official npm registry.

async-didi

Build Status

An async version of didi, the tiny dependency injection container for JavaScript.

Example

function Car(engine) {
  this.start = function() {
    engine.start();
  };
}

async function createEngine(power) {
  return {
    start: function() {
      console.log('Starting engine with ' + power + 'hp');
    }
  };
}

const {
  AsyncInjector
} = require('async-didi');

const injector = new AsyncInjector([
  {
    'car': ['type', Car],
    'engine': ['factory', createEngine],
    'power': ['value', 1184]
  }
]);

await injector.invoke(async function(car) {
  await car.start();
});

For more examples, check out the tests.

Comparison to didi

  • Same core features
  • Exposes an AsyncInjector
  • Injector API functions get, invoke and instantiate are async
  • Factory functions may be async
  • No support for child injectors and scopes

License

MIT

Current Tags

  • 0.2.1                                ...           latest (10 months ago)

4 Versions

  • 0.2.1                                ...           10 months ago
  • 0.2.0                                ...           10 months ago
  • 0.1.1                                ...           10 months ago
  • 0.1.0                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (11)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |