depinject
v0.2.8
Published
ES6 decorator to inject dependencies into classes
Downloads
2
Readme
depinject
ES6 decorator to inject dependencies into classes.
Usage
Install from npm
$ npm install depinject
Decorate classes with @inject
. Pass in an object map of desired dependencies. You can then access them with this.getDep(key)
, giving the key of the desired dependency.
Example:
import inject from 'depinject';
import http from 'http';
@inject({http, process})
class Foo {
someMethod() {
let http = this.getDep('http'),
process = this.getDep('process');
}
}