Skip to content

Commit

Permalink
Snapshot the Set of listeners when dispatching a BackAndroid event
Browse files Browse the repository at this point in the history
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 #5781.
Closes #5783

Reviewed By: svcscm

Differential Revision: D2911282

Pulled By: foghina

fb-gh-sync-id: 34964ec3414af85eb9574bbcef081238fc67ffaf
  • Loading branch information
fabianeichinger authored and facebook-github-bot-7 committed Feb 8, 2016
1 parent 81dc884 commit 9040315
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Libraries/Utilities/BackAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type BackPressEventName = $Enum<{
var _backPressSubscriptions = new Set();

RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() {
var backPressSubscriptions = new Set(_backPressSubscriptions);
var invokeDefault = true;
_backPressSubscriptions.forEach((subscription) => {
backPressSubscriptions.forEach((subscription) => {
if (subscription()) {
invokeDefault = false;
}
Expand Down

0 comments on commit 9040315

Please sign in to comment.