-
-
Notifications
You must be signed in to change notification settings - Fork 853
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
Issue 915: Stop/start Location manager based on listeners registered. #999
Conversation
Maps issue 915: Stop/start Location manager based on listeners registered.
@mfazekas Would you be able to have a look at the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks, nice work.
It would be great if you could summarise the issues fixed with the changes.
There are also some rename, which is not backward compatible. If the new names are better i'm all for it, but we must keep old versions working and showing a deprecation alert.
if (!this._listeners.includes(listener)) { | ||
this._listeners.push(listener); | ||
|
||
if (this._lastKnownLocation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this removed?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change reverted.
Reason for removing this, I was trying to keep addListener() and the method call listener() independent, but didn't work out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfazekas Please let me know if any more changes are required with this PR.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this, just added some comments.
Besides fixing failing tests it would be great if you would kindly add additional tests covering your changes.
🙇
@soumyashisPR, did you find the time to check the review comments? Thanks 🙇 |
Hey @ferdicus , have addressed the review comments. Let me know if there are further changes required. |
if (running) { | ||
locationManager.start(); | ||
|
||
const location = await locationManager.getLastKnownLocation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this the last time around, I think you can remove getLastKnownLocation
then from locationManager
as it's not being used anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this is actually being used in setLocationManager
if (running) { locationManager.addListener(this._onLocationUpdate); const location = await locationManager.getLastKnownLocation(); this._onLocationUpdate(location); } else { locationManager.removeListener(this._onLocationUpdate); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean... yeah, now it does after you reverted it again :)
Thanks @soumyashisPR, can you please address all comments. 🙇 Also, what seems to be the issue with the unit tests? Thanks again |
Is this PR going to create an issue for us who don't want the Location Manager running at all? For example, we are unmounting the |
Hey @systemlevel, according to the PR, unmounting |
Nevermind, the issue with unit tests is fixed. Thanks. |
@@ -80,7 +81,7 @@ describe('LocationManager', () => { | |||
expect(locationManager._listeners).toStrictEqual([myListener]); | |||
}); | |||
|
|||
test('does not readd same listener', () => { | |||
test('does not read same listener', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 're-add' make more sense here
test('does not read same listener', () => { | |
test('does not readd same listener', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @soumyashisPR for this PR and sorry it took a while :)
Lets get this out the door 🚪
…rnmapbox#999) * Fixed doc descriptions for Camera * Fixed documentation for Camera * Maps: location manager start/stop listening fix * Remove commented lines * Reaname boolean fields for UserLocation * fix unit tests * Fix unit test cases for location manager * Fix userlocation test * Add modified docs * PR review comment addressed * PR review comment addressed * PR review commit - reverted renames * Fix unit test * typo fix for read to re-add
Issue: react-native-mapbox-gl https://github.com/react-native-mapbox-gl/maps/issues/915
This issue was caused by UserLocation component as it was stopping the locationManager, which can be shared by other UserLocation instances.
Fix:
'UserLocation' should only add/remove its listener on 'locationManager' service and never start or stop it. It the responsibility of the locationManager to start or stop itself depending on the number of listeners registered.
EDIT ferdicus:
resolves #915