Snapshot the Set of listeners when dispatching a BackAndroid event
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 https://github.com/facebook/react-native/pull/5783 Reviewed By: svcscm Differential Revision: D2911282 Pulled By: foghina fb-gh-sync-id: 34964ec3414af85eb9574bbcef081238fc67ffaf
This commit is contained in:
parent
81dc884b2a
commit
90403154a2
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue