givemetheservice
v2.0.4
Published
ES6 dependency injection container.
Downloads
40
Maintainers
Readme
Give Me The Service
Give me the service is a ES6 dependency injection container for OOP.
npm install givemetheservice --save
Features
Services
Develop your own service in a separate file. Your don't need to instanciate it. GiveMeTheService DI do that job. If you use another service just inject it in your constructor.
What is the main avantage to use DI ?
You could easily override any service. Unit testing will be easy.
Just declare the service name in your constructor. Injected services are created as singleton.
class UserService {
constructor(config)
GiveMeTheService will create your service with its dependencies.
Lifecycle
- inject
- create()
- mount()
- unmount()
Test
To run our tests, clone the Qwebs repo and install the dependencies.
$ git clone https://github.com/BenoitClaveau/givemetheservice --depth 1
$ cd givemetheservice
$ npm install
$ cd tests
$ node.exe "../node_modules/mocha/bin/mocha" .