Skip to content
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

emmit complete on destroy component #4

Open
mgalante opened this issue Jul 17, 2020 · 1 comment
Open

emmit complete on destroy component #4

mgalante opened this issue Jul 17, 2020 · 1 comment

Comments

@mgalante
Copy link
Contributor

Hi Aleics!

Is it possible to trigger a complete event on destroy component?
I think it could be a nice feature in order to avoid manual unsubscriptions.
Have a nice day!

Miguel

@aleics
Copy link
Owner

aleics commented Aug 17, 2020

Hi Miguel,

Thank you for your request! At the moment, all the decorators are unaware and independent from the Angular lifecycles.

The main usage idea of the ngx-propserve library is to use it by following the SIP Principle, so the source streams are combined, by using the available rxjs operators, to create presentation streams that are consumed in the template. To extract the results of the stream, Angular provides the AsyncPipe, which unsubscribes the subscription of the piped stream automatically, when the component is destroyed.

That being said, I agree that internal subscriptions in the component are also a valid use case. What would be your idea on how to implement it, then? I could think of the decorator overwriting the ngOnDestroy function, so that the observed properties are completed when ngOnDestroy is being called. Probably, the component does not need to explicitly implement OnDestroy, so that ngOnDestroy is called by the Angular Engine when the component is destroyed. I think until-destroyed uses it this way as well.

Have a nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants