mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 04:50:59 +00:00
06a87bec25
- [ReactNative] Add AsyncStorageTest | Spencer Ahrens - [ReactNative] Add timers integration test | Spencer Ahrens - [ReactNative] Remove ExpandingText | Tadeu Zagallo - [TouchableHighlight] Preserve underlay style when restoring inactive props | Christopher Chedeau - clean flow errors in react-native-github | Basil Hosmer - [ReactNative] Sort React Native exports into two groups, Components and APIs | Christopher Chedeau - [ReactNative] Rename Slider to SliderIOS | Tadeu Zagallo - [react_native] JS files from D1919491: Improve JS logging | Martin Kosiba - [ReactNative] Add TimerExample | Spencer Ahrens - [RFC][ReactNative] increase timer resolution | Spencer Ahrens - [ReactNative] Strip prefixes from NativeModules keys | Spencer Ahrens - [ReactNative] Small docs cleanup in ActivityIndicatorIOS and DatePickerIOS | Christopher Chedeau - [ReactNative] Improvements on perf measurement output | Jing Chen - [ReactNative] Clean up Touchable PropTypes | Christopher Chedeau - [ReactKit] Fail tests when redbox shows up | Alex Kotliarskyi
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
*
|
|
* @providesModule IOSNativeBridgeEventPlugin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventPropagators = require('EventPropagators');
|
|
var NativeModules = require('NativeModules');
|
|
var SyntheticEvent = require('SyntheticEvent');
|
|
|
|
var merge = require('merge');
|
|
var warning = require('warning');
|
|
|
|
var RCTUIManager = NativeModules.UIManager;
|
|
|
|
var customBubblingEventTypes = RCTUIManager.customBubblingEventTypes;
|
|
var customDirectEventTypes = RCTUIManager.customDirectEventTypes;
|
|
|
|
var allTypesByEventName = {};
|
|
|
|
for (var bubblingTypeName in customBubblingEventTypes) {
|
|
allTypesByEventName[bubblingTypeName] = customBubblingEventTypes[bubblingTypeName];
|
|
}
|
|
|
|
for (var directTypeName in customDirectEventTypes) {
|
|
warning(
|
|
!customBubblingEventTypes[directTypeName],
|
|
"Event cannot be both direct and bubbling: %s",
|
|
directTypeName
|
|
);
|
|
allTypesByEventName[directTypeName] = customDirectEventTypes[directTypeName];
|
|
}
|
|
|
|
var IOSNativeBridgeEventPlugin = {
|
|
|
|
eventTypes: merge(customBubblingEventTypes, customDirectEventTypes),
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
|
|
var directDispatchConfig = customDirectEventTypes[topLevelType];
|
|
var event = SyntheticEvent.getPooled(
|
|
bubbleDispatchConfig || directDispatchConfig,
|
|
topLevelTargetID,
|
|
nativeEvent
|
|
);
|
|
if (bubbleDispatchConfig) {
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
} else if (directDispatchConfig) {
|
|
EventPropagators.accumulateDirectDispatches(event);
|
|
} else {
|
|
return null;
|
|
}
|
|
return event;
|
|
}
|
|
};
|
|
|
|
module.exports = IOSNativeBridgeEventPlugin;
|
|
|