View on GitHub

coredi

Dependency Injection library for Node.js and Browser

Service resolving

When you need get a service by name. You can run container as a function. For example:

container('myservice')

That means, “Get me a service with name ‘myservice’‘“.

Resolving with parameter

For convenience, we added “service name with parameter” possibility.

How it works? You can use it like this:

container('myservice:param')

it’s equals to:

container('myservice')('param')

That very helpful, when you implement some services, for example log service.

You can implement it like this:

container('log').log('warn', 'mymessage');

Or:

container('log:warn').log('mymessage');

Resolve service in another container

If you need get a service in another container you can get it like this:

container('myservice@mycontainer');

You can use with parameter:

container('myservice@mycontainer:myparam');