0.8.0 • Published 3 years ago

lightweight-di v0.8.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Lightweight Dependency Injection

npm version travis build status

A dependency injection library for node and the browser, based on Angulars DI. Optimized for use via TypeScript or babel decorators.

Getting started

1. Install the library in your project

npm install --save lightweight-di

2. Import the required decorators from the package

// TypeScript / Babel / Webpack
import { Injectable } from 'lightweight-di';

// Node.js / Browserify
const { Injectable } = require('lightweight-di');

3. Decorate classes with dependencies

@Injectable
class FileLogger {
    constructor(private fs: FileSystem) { }
    log(message: string) {
        fs.appendToFile('app.log', message);
    }
}

4. Bootstrap your application entry point with Injector

import { Injector } from 'lightweight-di';
const injector = Injector.resolveAndCreate([App, Dependency1, Dependency2]);
injector.get(App).run();

Documentation & Examples

For the full API check out the documentation or the examples on GitHub.

License

MIT

0.8.0

3 years ago

0.7.0

3 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago