zazoomauro / node-dependency-injection

The NodeDependencyInjection component allows you to standarize and centralize the way objects are constructed in your application.
https://github.com/zazoomauro/node-dependency-injection/wiki
MIT License
280 stars 34 forks source link

Autowiring for Pure Javascript #124

Closed zazoomauro closed 2 years ago

zazoomauro commented 5 years ago

Example:

imagine we have something like this in: services/someClient.js

export default class SomeClient 
{
...
}
services:
    _defaults:
        autowire: true

and then you can start using your SomeClient automatically like this:

export default class HelloWorldService
{
    constructor(someClient)
    {
        this._someClient = someClient
    }
}

Implementation:

zazoomauro commented 2 years ago

I spent some days working on it and I think this is not the right approach... May we have to rethink the main idea of autowiring on pure javascript I'll close this issue