A simple inversion of control (IOC) container. TypeScript based lightweight annotation-based dependency injection container.
You can install this package using NPM:
npm i ioc-container-simple
import { Registry, registry, inject } from '@ravinpatel/ioc-container-simple';
class C {
@inject() public readonly registry: Registry
}
class B {
@inject() public readonly c: C
}
class A {
@inject() public readonly b: B
}
@registry([A, B, C])
class App {
@inject()
public readonly a: A
}
import { inject } from './inject';
class MyClass {
@inject({ name: 'CustomNameForDependencyA' })
dependencyA!: DependencyA;
@inject({ name: 'CustomNameForDependencyB' })
dependencyB!: DependencyB;
}
import { inject } from './inject';
class MyClass {
@inject({ name: 'CustomNameForDependencyA' })
dependencyA!: DependencyA;
@inject({ name: 'CustomNameForDependencyB' })
dependencyB!: DependencyB;
}
npm run test
npm run lint