Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@tobes31415/dependency-injection

1.0.2 • 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

Install

npm i @tobes31415/dependency-injection

DownloadsWeekly Downloads

6

Version

1.0.2

License

MIT

Unpacked Size

27.6 kB

Total Files

17

Last publish

Collaborators

  • avatar