closure-box
Simple DI container with flow
Last updated 3 years ago by sota1235 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install closure-box 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.1                                ...           latest (3 years ago)

1 Versions

  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |