closure-box

0.0.1 • Public • Published

ClosureBox

Simple DI container with flow for Node.js

Description

Simple DI container with using flow.

Requirement

You need to remove flow annotation with using transform-flow-strip-types plugin or flow-remove-types.

Usage

Exported container is singleton instance.

Set instance.

import UserRepository from 'repositories/user-repository';
import AuthService from 'services/auth-service';
import Container from 'closure-box';
 
Container
  .set('UserRepositoryInterface', () => {
    return new UserRepository();
  })
  .set('services/auth-service', (container: type of Container) => {
    return new AuthService(container.get('UserRepositoryInterface'));
  });

Get instance.

import AuthService from 'services/auth-service';
import Container from 'closure-box';
 
const authService: AuthService = Container.get('services/auth-service');

Just it.

Install

TBD

Contribution

Please give me Pull Request :)

Licence

This software is released under the MIT License, see LICENSE.txt.

Author

@sota1235

Readme

Keywords

Package Sidebar

Install

npm i closure-box

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • sota1235