New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why we storing services in property? #1

Closed
vforv opened this Issue Apr 20, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@vforv
Copy link

vforv commented Apr 20, 2018

Hello I saw this looks pretty good.

But I have not understand why we using service property when we don't using it when resolving dependencies?

Here:

protected services: Map<string, Type<any>> = new Map<string, Type<any>>();

Also how is it possible to mock some dependencies?

Thanks

@nehalist

This comment has been minimized.

Copy link
Owner

nehalist commented Apr 21, 2018

Good point. It's actually a copy/paste mistake from my very own injector, which is able to store resolved instances and return them in case the services are shared. But, nevertheless, you're completely right about storing services in this case is completely useless.

Will update the article asap, thank you.

@vforv

This comment has been minimized.

Copy link

vforv commented Apr 21, 2018

Aha, okay. Anyway article helped me create small DI framework, thanks!

@kpfromer

This comment has been minimized.

Copy link

kpfromer commented Apr 22, 2018

@nehalist is it possible that you could link your more advanced injector? It would be cool to see how it works.

@nehalist

This comment has been minimized.

Copy link
Owner

nehalist commented Apr 23, 2018

@kpfromer you could take a look at https://github.com/inversify/InversifyJS. Otherwise just search for "github ts di" to find some more advanced DI systems.

@nehalist nehalist closed this in 2857c50 May 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment