mench / dependency-injection-es6

MIT License
16 stars 1 forks source link

Allow circular dependencies? #3

Open Dri4n opened 7 years ago

Dri4n commented 7 years ago

Hi,

this library allow circular depedencies ? and create globaly one instance on app..

Thanks.

mench commented 7 years ago

I think you can do something like this to solve this issue;

class One { @inject( ()=> { return Two; }) two:Two; }

class Two { @inject(One) one:One; } let app = container.resolve(Two); console.info(app.one.two);

But I am not sure that it will work correctly on all use cases.