inversify-extension
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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-metadata

Examples

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");

Readme

Keywords

none

Package Sidebar

Install

npm i inversify-extension

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

9.99 kB

Total Files

15

Last publish

Collaborators

  • alexgladin