Closed xLama closed 2 years ago
It would be very nice if we could choose went to apply the decorator functionality. For me, i also need to execute this functionality before my component's ngOnDestroy in some cases.
+1
Is there any case where you would prefer the current behavior?
Is there any case where you would prefer the current behavior?
I think both behaviors are useful. I use current behavior to exe code before unsuscriptions, like "ngOnUnsuscription", the last chance to do something.
I don't think this somehow brings any benefit for users.
Currently, subscriptions are unsubscribed after the original ngOnDestroy
is called. Which means you're capable of doing the reset logic in your ngOnDestroy
. You can also do the reset logic in finalize
.
What's the benefit then?
It should be interesting execute ngOnDestroy later (with a flag) to be able prevent subscription executions in ngOnDestroy. It is usefull with NGRX Store because we want to reset store on destroy component.
POC
https://stackblitz.com/edit/angular-ivy-yke7ut?file=src%2Fapp%2Fcomponents%2Fprimary%2Fprimary.component.ts
My proposal https://github.com/xLama/until-destroy/pull/1