Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Execute ngOnDestroy later #195

Closed
xLama opened this issue May 3, 2022 · 5 comments
Closed

Execute ngOnDestroy later #195

xLama opened this issue May 3, 2022 · 5 comments

Comments

@xLama
Copy link

xLama commented May 3, 2022

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
xLama#1

@aalvarez-stratio
Copy link

aalvarez-stratio commented May 6, 2022

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.

@Jpascual55
Copy link

+1

@xLama xLama changed the title Execute ngOnDestroy first Execute ngOnDestroy later May 6, 2022
@NetanelBasal
Copy link
Member

Is there any case where you would prefer the current behavior?

@xLama
Copy link
Author

xLama commented Jun 10, 2022

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.

@arturovt
Copy link
Collaborator

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?

@ngneat ngneat locked and limited conversation to collaborators Jul 4, 2022
@arturovt arturovt converted this issue into discussion #204 Jul 4, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants