question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please remove warning - Called stopObserving with existing subscriptions

See original GitHub issue

https://github.com/Agontuk/react-native-geolocation-service/blob/master/js/Geolocation.android.js#L87

Even if we call clearWatch before stopObserving, this warning is fired every time and gets very annoying. Can we get the warning removed? Or what’s the right way to prevent it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
Agontukcommented, Feb 18, 2021

The documentation for stopObserving() says: “Stops observing for device location changes. In addition, it removes all listeners previously registered.”. From this I understand that if there are some listeners, they will be removed when stopObserving() is called. Am I misinterpreting this?

No you’re right.

clearWatch will clear a specific subscription and then check if there’s any active watcher. If there’s none, it’ll call stopObserving to shut down the native location updates.

stopObserving will shut down the native location updates immediately, then proceeds to check if there’s any active watchers. If there are active watchers, it’ll print a warning to let developers know they still have active watchers before clearing all of them.

Printing the warning is actually useful for developers, who mistakenly called stopObserving. If you’re knowingly calling it to stop location updates & getting annoyed with the warning, you can ignore it using YellowBox api. Also this only affects development, it has no effect in production.

1reaction
Agontukcommented, Oct 11, 2020

hi @Agontuk, If I only use clearWatch, after component is unmount, the location is still being tracked, so I’m forced to using stopObserving, and the warnings are still showing. Is this expected behavior?

Can you provide a sample code ? This shouldn’t be possible, clearWatch removes location tracking when called.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to call stopObserving() from navigator.geolocation ...
However, that gives me the warning: Called stopObserving without existing subscriptions. I have no idea what to make of it.
Read more >
How to use the fbjs/lib/warning function in fbjs - Snyk
To help you get started, we've selected a few fbjs/lib/warning examples, ... if (sub) { warning(false, 'Called stopObserving with existing subscriptions.
Read more >
IntersectionObserver.unobserve() - Web APIs | MDN
The IntersectionObserver method unobserve() instructs the IntersectionObserver to stop observing the specified target element.
Read more >
Solved: Re: How does a parent stop observing a student ...
I have some parents that would like to stop observing or unlink their accounts to former students. How can they accomplish this task?...
Read more >
Using the Service Observe feature on Windows clients
Use this procedure to use the Service Observe feature to listen in and possibly talk on calls to extensions, attendants, agents, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found