@biorate/inversion
TypeScript icon, indicating that this package has built-in type declarations

1.65.4 • Public • Published

Inversion

IoC core module build on InversifyJS

Example:

import { Core, init, injectable, inject, container, kill } from '@biorate/inversion';

@injectable()
class One {
  @init() public initialize() {
    console.log('One module initialized');
  }

  @kill() public kill() {
    console.log('One module killed');
  }
}

@injectable()
class Two {
  @init() public initialize() {
    console.log('Two module initialized');
  }
}

@injectable()
class Three {
  @init() public initialize() {
    console.log('Three module initialized');
  }
}

class Root extends Core() {
  @inject(One) public one;
  @inject(Two) public two;
  @inject(Three) public three;
}

container.bind(One).toSelf();
container.bind(Two).toSelf();
container.bind(Three).toSelf();
container.bind(Root).toSelf();

const root = container.get(Root);

root.$run().then(() => {
  console.log(root.one instanceof One); // true
  console.log(root.two instanceof Two); // true
  console.log(root.three instanceof Three); // true
});

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Readme

Keywords

none

Package Sidebar

Install

npm i @biorate/inversion

Weekly Downloads

11

Version

1.65.4

License

MIT

Unpacked Size

210 kB

Total Files

44

Last publish

Collaborators

  • llevkin