-
Notifications
You must be signed in to change notification settings - Fork 171
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
Feature - Unregister a token #190
base: master
Are you sure you want to change the base?
Conversation
It is a missing feature. I have been using stuff like below which I am nervous about. It would be good to use it legally. 😀
|
I have always been pretty leery of this feature. I get that it might be useful for testing, but I fear that it would create situations where an object can be resolved but not be able to be resolved later. @Xapphire13, what do you think? |
Hi guys, any update on this Pull Request? We need this feature in our React application to remove a ViewModel Singleton class from memory when a component is destroyed. |
@wagnercsfilho we are waiting for @Xapphire13 feedback. |
Alright, I think we can accept this PR - please update the readme, and I'll accept it and push out a new version this week. You may need to rebase too (I'm not totally sure) |
@MeltingMosaic I pulled the latest updates and added a description for the |
@wladimirgrf updates about this? |
Hi @wagnercsfilho. No updates. |
Just sharing what I'm facing with the tsyringe and AWS lambdas. Every request, I need to register a runtime value to be used inside the lambda code, that's ok and works perfectly. But when a next request comes in, the value registered in the last request is still present and in this scenario it can be considered as a data leak. In this case I cannot allow a value from a previous request to be present in the next requests. That's why I need the This is not a big problem yet because I'm overwriting the old runtime value in every request. But there could be other scenarios that can be very problematic. |
Added this to tsyringe-neo |
There are features in tsyringe for removing/cleaning all instances. It is not possible to choose a specific token to delete.
This pull request enables unregister a token. Solving two issues:
.reset()
removes all registrations #82Example
The
test1
should log the message without any problems, however thetest2
will return an error message:Attempted to resolve unregistered dependency token...
Because unregister removed the corresponding key.