depinject

0.2.8 • Public • Published

depinject

Build Status Dependencies

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');
	}
}

Readme

Keywords

none

Package Sidebar

Install

npm i depinject

Weekly Downloads

1

Version

0.2.8

License

MIT

Last publish

Collaborators

  • tkuminecz