Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.

Unsubscribe the observer #30

Closed
ambraspace opened this issue Feb 23, 2022 · 1 comment
Closed

Unsubscribe the observer #30

ambraspace opened this issue Feb 23, 2022 · 1 comment

Comments

@ambraspace
Copy link

ambraspace commented Feb 23, 2022

🚀 Feature request

Is there a way to easily unsubscribe from Observable (geolocation service)?

When moving away from a component which uses geolocation service, I would like to stop observing the position. I couldn't find direct method to do that.

When I move back to the same component, it subscribes again and I have now two observers monitoring user position. If I do it again, I would have three observers firing at the same time with updated position.

Since I couldn't find direct solution, I used pipe with takeWhile, but it looks awkward.

@waterplea
Copy link
Member

In this regard it is just the same as any other Observable. You can use async pipe in template to automate subscription, change detection and unsubscription. Or you can manually add takeUntil and use some destroy stream + ngOnDestroy.

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

No branches or pull requests

2 participants