InversifyJS
InversifyJS copied to clipboard
Investigate support for @preDestroy
Investigate @preDestroy see https://github.com/inversify/InversifyJS/issues/587#issuecomment-311881952 for more info...
Remo, I find that very interesting.
Do you mean in general we need to provide some kind of a LifeCycleManager to handle the lifecycle calls or attach on* methods on the container similar to Windsor
https://github.com/castleproject/Windsor/blob/aa9b8b353ee2e533d586495eec254e216f800c09/docs/lifecycle.md?
What do you think of the usage of interceptors? That potentially will give a different way of doing the onActivation handling
https://github.com/castleproject/Windsor/blob/aa9b8b353ee2e533d586495eec254e216f800c09/docs/interceptors.md#interceptors.
Also, I was thinking of investigating of pairing them up with mixin style calls similar maybe to Django Rest Framework mixins http://www.django-rest-framework.org/tutorial/3-class-based-views/#using-mixins.
or this article
https://blog.mariusschulz.com/2017/05/26/typescript-2-2-mixin-classes
The idea is to attach mixins than are used independently for each lifecycle call.
What do you think?
I'd like this very much. The typical case for me is working with Observables. If you subscribe to an observable within a service that is not a singleton, you should unsubscribe once the service is destroyed, otherwise you'll get notifications in a service that doesn't exist anymore.
I'd would like this feature as well. We have a simmilar use case where we have a set of handlers for web socket messages. Currently we have to ensure the handlers live in singletone scope all the time or manage the lifecycle ourself as we do not know when to detach the handlers.
Having @preDestroy would make the code more SOLID as now we have to handle some concerns out of bean definition.
@remojansen @parisholley has preDestroy been recently removed from any tags or npm releases? It seems to still exist on master but when I install 5.1.1 via NPM the preDestroy annotation is completely missing.
I also don't see onDeactivation handler for a Container instance and for a type binded in singleton scope.
@remojansen why isn't it in the NPM package?
https://github.com/inversify/InversifyJS/issues/1319 - i don't think authors intend to push async changes until v6
i also have an old build of my initial PR here that has all of the working async functionality, though their may be slight differences between it and master: https://www.npmjs.com/package/@parisholley/inversify-async
#1319 - i don't think authors intend to push async changes until v6
@parisholley, the documentation in the master branch is misleading: https://github.com/inversify/InversifyJS/blob/master/wiki/pre_destroy.md and https://github.com/inversify/InversifyJS/blob/master/wiki/deactivation_handler.md
#1319 - i don't think authors intend to push async changes until v6
you are right. I don't know what happened with the wiki. hopefully we finish work on v5 soon. Then I think we can release a v6.
@dcavanagh