@di-extra/inversify
v0.2.0
Published
Type-safe Dependency Injection Wrapper for inversify
Downloads
13
Maintainers
Readme
@di-extra/inversify
Type-safe Dependency Injection Wrapper for inversify
Currently, support inversify v6
Getting Started
Install dependencies
npm install @di-extra/inversify
Usage
See full example in example/inversify
import 'reflect-metadata';
import { container } from './container';
import { injector } from '@di-extra/inversify';
// Import all related dependencies services
injector(container)
.inject('dataService', DataService).to<DataService>()
.inject('service', Service).to<Service>()
.inject('option', Tokens.Option).to<Option>()
.resolve(({ dataService, service, option }) => {
console.log(`service.getData()`, service.getData());
console.log(`dataService.getData()`, dataService.getData());
console.log(`option`, option);
});
Output:
service.getData() Getting data from Hey I'm DataService
dataService.getData() Hey I'm DataService
option { name: 'test-value' }