@tobes31415/dependency-injection
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

DI

A tiny library to handle basic dependency injection

View API Docs

Installation

npm install --save @tobes31415/di

Basic Useage

import { DI } from "@tobes31415/dependency-injection";
import { SomeService } from "./someService";

class SomeClass {
    constructor() {
        this.service = DI.resolve(SomeService);
    }
}

Advanced Useage

DI.useClass(Potato, Carrot);
const obj = DI.resolve(Potato) // instance of Carrot

DI.useObject(Potato, {banana});
const obj = DI.resolve(Potato) // {banana}

DI.useFactory(Potato, () => 123);
const obj = DI.resolve(Potato) //123

Package Sidebar

Install

npm i @tobes31415/dependency-injection

Weekly Downloads

128

Version

3.0.0

License

MIT

Unpacked Size

40.8 kB

Total Files

19

Last publish

Collaborators

  • tobes31415