react-native-macos/Libraries/Utilities
Daniel Friesen 165b38ab7a Remove usage of the ... operator in BackHandler
Summary:
This usage of `...` currently causes BackHandler to silently become non-functional when a `Symbol` polyfill is used.

Why?
- The `[...obj]` operator implicitly calls the object's iterator to fill the array
- react-native's internal `Set` polyfill has a load order issue that breaks it whenever a project uses a `Symbol` polyfill
- This means that when `BackHandler` tries to `[...set]` a `Set` of subscriptions the result is always an empty array instead of an array of subscriptions

Additionally it's worth noting that the current code is also wastefully inefficient as in order to reverse iterate over subscriptions it:
- Clones the `Set` (which fills it by implicitly running the set's iterator)
- Uses `[...set]` to convert the cloned set into an array (which also implicitly runs the iterator on the clone)
- Finally reverses the order of the array

----

This code fixes this problem by replacing the use of multiple Set instance iterators with a simple `.forEach` loop that unshifts directly into the final array.

I've tested this by opening the repo's RNTester app on Android and tvOS ensuring that the back handler works before changes, the application crashes when I introduce an error (to verify my code changes are being applied to the app), the back handler works and after changes.

Fixes #11968
Closes https://github.com/facebook/react-native/pull/15182

Differential Revision: D6114696

Pulled By: hramos

fbshipit-source-id: 2eae127558124a394bb3572a6381a5985ebf9d64
2017-10-20 18:02:14 -07:00
..
__mocks__ Add mock for BackHandler 2017-04-11 12:25:38 -07:00
__tests__ Extend unit test for buildStyleInterpolator 2017-10-02 17:05:28 -07:00
differ remove disableAutomock from jest tests (new default) @bypass-lint 2017-06-13 15:04:09 -07:00
BackAndroid.js Move BackAndroid -> BackHandler, add Apple TV support for back nav 2017-03-06 21:51:40 -08:00
BackHandler.android.js Remove usage of the ... operator in BackHandler 2017-10-20 18:02:14 -07:00
BackHandler.ios.js Remove usage of the ... operator in BackHandler 2017-10-20 18:02:14 -07:00
DebugEnvironment.js gets Relay/Classic/Compat building 2017-07-24 21:39:00 -07:00
DeviceInfo.js require `fbjs/lib/invariant`, not `invariant` 2017-03-21 05:37:03 -07:00
Dimensions.js Run eslint --fix 2017-10-09 17:46:44 -07:00
HMRClient.js Auto-fix lint errors 2016-08-09 06:43:46 -07:00
HMRLoadingView.android.js Show a Toast for HMR 2016-02-27 15:58:35 -08:00
HMRLoadingView.ios.js Show a Toast for HMR 2016-02-27 15:58:35 -08:00
HeapCapture.js upload JSC heap capture to bundle server 2016-08-02 08:13:57 -07:00
MatrixMath.js Fix license headers 2017-03-08 00:52:17 -08:00
PerformanceLogger.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
PixelRatio.js Run eslint --fix 2017-10-09 17:46:44 -07:00
Platform.android.js Merge AndroidConstants and IOSConstants into PlatformConstants 2017-02-22 15:01:11 -08:00
Platform.ios.js Merge AndroidConstants and IOSConstants into PlatformConstants 2017-02-22 15:01:11 -08:00
RCTLog.js Run eslint --fix 2017-10-09 17:46:44 -07:00
SceneTracker.js Add option to track when we're showing blankness during fast scrolling 2017-04-07 01:00:39 -07:00
binaryToBase64.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
buildStyleInterpolator.js Avoid eval in buildStyleInterpolator 2017-10-02 17:05:34 -07:00
clamp.js fix params order in comments clamp.js 2017-09-29 00:01:10 -07:00
createStrictShapeTypeChecker.js Run eslint --fix 2017-10-09 17:46:44 -07:00
deepFreezeAndThrowOnMutationInDev.js Android: fix JSC crash in dev 2017-01-11 08:58:30 -08:00
defineLazyObjectProperty.js Break infinite loop that happens only in debug environments 2017-01-17 16:58:46 -08:00
deprecatedPropType.js Patch up for future React Sync 2017-02-08 14:50:43 -08:00
dismissKeyboard.js Fix license headers 2017-03-08 00:52:17 -08:00
groupByEveryN.js Flowify Library/Utilities/ 2015-03-23 16:47:26 -08:00
infoLog.js Change all calls to no-console from no-console-disallow 2017-09-29 16:38:06 -07:00
logError.js Fix react-native function call arity errors 2017-05-18 16:55:55 -07:00
mapWithSeparator.js Optimize and flowify mapWithSeparator 2016-05-26 12:28:55 -07:00
mergeFast.js Fix typo 2015-08-06 20:22:24 -08:00
mergeIntoFast.js Bugfix - Typos 2015-12-15 09:09:32 -08:00
stringifySafe.js [ReactNative] improve console logging a little bit 2015-05-04 18:57:03 -08:00
truncate.js Auto-fix lint errors 2016-08-09 06:43:46 -07:00
utf8.js Add support for missing XHR response types 2016-04-11 05:54:28 -07:00