-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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): maintain subscriptions across event targets #20897
fix(google-maps): maintain subscriptions across event targets #20897
Conversation
src/google-maps/map-event-manager.ts
Outdated
@@ -18,11 +19,11 @@ export class MapEventManager { | |||
/** Pending listeners that were added before the target was set. */ | |||
private _pending: {observable: Observable<any>, observer: Subscriber<any>}[] = []; | |||
private _listeners: google.maps.MapsEventListener[] = []; | |||
private _target: MapEventManagerTarget; | |||
private _targets = new BehaviorSubject<MapEventManagerTarget>(undefined); |
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 this member name is a little confusing. It implies there are several targets at the same time, when in fact there is still just a single target.
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.
Also, should the type be BehaviorSubject<MapEventManagerTarget|undefined> ?
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.
My thinking with making it plural was that it's a "stream of targets", but since we don't follow the $
suffix convention for observables, there wasn't a better way to indicate it. I'll rename it.
As for the | undefined
, it's not necessary since MapEventManagerTarget
includes undefined
already.
This came up during the review of angular#20873. Currently the class that manages events for the Google Maps objects assumes that once a target is assigned, it'll either be maintained or eventually removed which means that the fix from angular#20873 will cause any existing event listeners to be dropped. These changes add some code which will preserve the listeners. Furthermore, I've added a dedicated testing setup for the `MapEventManager` since there's a fair bit of logic encapsulated in it and we've only been testing it by proxy through the various Google Maps components.
f099676
to
cc56523
Compare
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
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 came up during the review of #20873. Currently the class that manages events for the Google Maps objects assumes that once a target is assigned, it'll either be maintained or eventually removed which means that the fix from #20873 will cause any existing event listeners to be dropped. These changes add some code which will preserve the listeners. Furthermore, I've added a dedicated testing setup for the `MapEventManager` since there's a fair bit of logic encapsulated in it and we've only been testing it by proxy through the various Google Maps components. (cherry picked from commit cc503c4)
This came up during the review of #20873. Currently the class that manages events for the Google Maps objects assumes that once a target is assigned, it'll either be maintained or eventually removed which means that the fix from #20873 will cause any existing event listeners to be dropped. These changes add some code which will preserve the listeners. Furthermore, I've added a dedicated testing setup for the `MapEventManager` since there's a fair bit of logic encapsulated in it and we've only been testing it by proxy through the various Google Maps components. (cherry picked from commit cc503c4)
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. |
This came up during the review of #20873. Currently the class that manages events for the Google Maps objects assumes that once a target is assigned, it'll either be maintained or eventually removed which means that the fix from #20873 will cause any existing event listeners to be dropped.
These changes add some code which will preserve the listeners.
Furthermore, I've added a dedicated testing setup for the
MapEventManager
since there's a fair bit of logic encapsulated in it and we've only been testing it by proxy through the various Google Maps components.