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

fix(google-maps): unable to subscribe to events after initialization #17845

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

crisbeto
Copy link
Member

As things are set up right now in the google-map, map-marker and map-info-window components we choose whether to bind an event based on whether there are subscribers to its observable. The problem is that if the user decides to subscribe after init (e.g. by getting a hold of object with ViewChild and subscribing) it'll never emit because the native event wasn't added.

These changes fix the issue by switching the event to be observables and binding the event when something has subscribed. I've also introduced a MapEventManager class to make it easier to keep track of the events and to avoid duplication between the three components.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent pr: merge safe target: patch This PR is targeted for the next patch release labels Nov 30, 2019
@crisbeto crisbeto requested a review from a team as a code owner November 30, 2019 12:00
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 30, 2019
@jelbourn jelbourn requested a review from mbehrlich December 2, 2019 18:38
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extremely good change, just one naming nit

Copy link
Collaborator

@mbehrlich mbehrlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! If it's not too much trouble, can you update the most recent component that was just added, MapPolyline as well?

As things are set up right now in the `google-map`, `map-marker` and `map-info-window` components we choose whether to bind an event based on whether there are subscribers to its observable. The problem is that if the user decides to subscribe after init (e.g. by getting a hold of object with `ViewChild` and subscribing) it'll never emit because the native event wasn't added.

These changes fix the issue by switching the event to be observables and binding the event when something has subscribed. I've also introduced a `MapEventManager` class to make it easier to keep track of the events and to avoid duplication between the three components.
@crisbeto crisbeto force-pushed the map-events-after-init branch from 2de37ac to 1758d40 Compare December 4, 2019 19:34
@crisbeto
Copy link
Member Author

crisbeto commented Dec 4, 2019

I've addressed the feedback @jelbourn @mbehrlich.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Dec 4, 2019
@jelbourn jelbourn merged commit 22fecb3 into angular:master Dec 4, 2019
crisbeto added a commit to crisbeto/material2 that referenced this pull request Dec 22, 2019
Looks like a regression from angular#17845 where the name of the `zoom_changed` even was mistyped.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Dec 22, 2019
Looks like a regression from angular#17845 where the name of the `zoom_changed` even was mistyped.

Fixes angular#18026.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants