@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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 3.0.0
    199
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 3.0.0
    199
  • 2.0.0
    1
  • 1.0.2
    1
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i @tobes31415/dependency-injection

Weekly Downloads

178

Version

3.0.0

License

MIT

Unpacked Size

40.8 kB

Total Files

19

Last publish

Collaborators

  • tobes31415