-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(google-maps): handle trying to access the map before it has been initialized #17805
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
Conversation
jelbourn
left a comment
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.
Rather than letting everything no-op when the map is undefined, it seems like throwing an error would be better (a real error, not just "Cannot read xxx of null") so people know what they're doing is invalid
|
Isn't that somewhat prone to race conditions? The consumer has no way of knowing when the maps has been initialized. |
|
If we no-op, the user still hits the race condition, they just get no feedback that it happened and that their call did nothing. Without these methods being |
…initialized As things are set up at the moment, the Google `Map` object will be initialized once the API has loaded, however all of the methods on the `GoogleMap` component assume that the object will always be defined. This means that if any of the methods are called before it is initialized, we'll throw a null pointer error. These changes add a more readable error so people know what to do.
29afab4 to
549af93
Compare
|
I've reworked it based on the discussion @jelbourn. |
jelbourn
left a comment
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.
LGTM
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
As things are set up at the moment, the Google
Mapobject will be initialized once the API has loaded, however all of the methods on theGoogleMapcomponent assume that the object will always be defined. This means that if any of the methods are called before it is initialized, we'll throw a null pointer error. These changes add a more readable error so people know what to do.