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

1.0.1 • Public • Published

@sanjo/dependency-injection-container

This work is devoted to God.

A dependency injection container.

How to install

npm install --save '@sanjo/dependency-injection-container'

How to use

import { DependencyInjectionContainer } from '@sanjo/dependency-injection-container'
import { DependingOn } from './DependingOn.js'

const container = new DependencyInjectionContainer()

class DatabaseA {

}

const database = new DatabaseA()
container.register('database', database)

class ComponentB implements DependingOn {
  database: any

  static getDependencies() {
    return ['database']
  }
}

const componentB = container.instantiate<ComponentB>(ComponentB)

console.log(componentB.database)

Package Sidebar

Install

npm i @sanjo/dependency-injection-container

Weekly Downloads

2

Version

1.0.1

License

Unlicense

Unpacked Size

8.17 kB

Total Files

20

Last publish

Collaborators

  • sanjo