-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Snapshot the Set of listeners when dispatching a BackAndroid event #5783
Snapshot the Set of listeners when dispatching a BackAndroid event #5783
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
var _backPressSubscriptions = new Set(); | ||
|
||
RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() { | ||
_copySubsSetInsteadOfModify = true; | ||
var backPressSubscriptions = _backPressSubscriptions; | ||
|
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.
no-trailing-spaces: Trailing spaces not allowed.
I think this is right. Node's event emitter snapshots the set of event handlers when the event is first fired. We should probably always copy the handler set -- the bookkeeping with the boolean is complicated. |
Isn't it easier to just copy it every time in the listener? |
Yeah, you are right, this is too complicated for what it is doing. |
9c3e174
to
8403608
Compare
@feichngr updated the pull request. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thanks for the PR! @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1101528873231987/int_phab to review. |
9040315
Summary: …while an event is dispatched While it is guarded, a copy of the Set is created before listeners are added or removed. The event dispatch loop continues with the old Set of listeners. This PR modifies `BackAndroid` to match the proposal at the end of facebook#5781. Closes facebook#5783 Reviewed By: svcscm Differential Revision: D2911282 Pulled By: foghina fb-gh-sync-id: 34964ec3414af85eb9574bbcef081238fc67ffaf
…while an event is dispatched
While it is guarded, a copy of the Set is created before listeners are added or removed. The event dispatch loop continues with the old Set of listeners.
This PR modifies
BackAndroid
to match the proposal at the end of #5781.