1.0.1 • Published 5 years ago
inversify-extension v1.0.1
InversifyJS Extension
About
InversifyJS Extension is project
Installation
You can get the latest release and the type definitions using npm:
$ npm install inversify inversify-extension reflect-metadataExamples
AutoNamed factory
The old way for writing named factory:
container.bind<interfaces.Factory<Katana>>("Factory<Katana>")
  .toFactory<Katana>((context: interfaces.Context) => (named: string): Katana => {
    return context.container.getNamed<Katana>("Katana", named);
  });Now you can write in a more simple way:
import { ContainerExtension } from 'inversify-extension';
const container = new ContainerExtension();
container.bind<interfaces.Factory<Katana>>("Factory<Katana>")
  .toAutoNamedFactory<Katana>("Katana");The same way for a factory that works with tags:
import { ContainerExtension } from 'inversify-extension';
const container = new ContainerExtension();
container.bind<interfaces.Factory<Katana>>("Factory<Katana>")
  .toAutoTaggedFactory<Katana>("Katana");