mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
* Convert EventPlugin{Hub,Registry} to named exports
* Convert EventPluginUtils to named exports
* Convert EventPropagators to named exports
* Convert ReactControlledComponent to named exports
* Convert ReactGenericBatching to named exports
* Convert ReactDOMComponentTree to named exports
* Convert ReactNativeComponentTree to named exports
* Convert ReactNativeRTComponentTree to named exports
* Convert FallbackCompositionState to named exports
* Convert ReactEventEmitterMixin to named exports
* Convert ReactBrowserEventEmitter to named exports
* Convert ReactNativeEventEmitter to named exports
* Convert ReactDOMEventListener to named exports
* Convert DOMMarkupOperations to named exports
* Convert DOMProperty to named exports
* Add suppression for existing Flow violation
Flow didn't see it before.
* Update sizes
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import {batchedUpdates} from 'events/ReactGenericBatching';
|
|
// Module provided by RN:
|
|
import BatchedBridge from 'BatchedBridge';
|
|
|
|
import {getFiberCurrentPropsFromTag} from './ReactNativeRTComponentTree';
|
|
|
|
var ReactNativeRTEventEmitter = {
|
|
/**
|
|
* Publicly exposed method on module for native objc to invoke when a top
|
|
* level event is extracted.
|
|
* @param {rootNodeID} rootNodeID React root node ID that event occurred on.
|
|
* @param {TopLevelType} topLevelType Top level type of event.
|
|
* @param {object} nativeEventParam Object passed from native.
|
|
*/
|
|
receiveEvent: function(
|
|
tag: number,
|
|
topLevelType: string,
|
|
nativeEventParam: Object,
|
|
) {
|
|
var nativeEvent = nativeEventParam;
|
|
var props = getFiberCurrentPropsFromTag(tag);
|
|
if (props == null) {
|
|
return;
|
|
}
|
|
var eventHandler = props[topLevelType];
|
|
if (typeof eventHandler !== 'function') {
|
|
return;
|
|
}
|
|
batchedUpdates(function() {
|
|
eventHandler(nativeEvent);
|
|
});
|
|
},
|
|
};
|
|
|
|
BatchedBridge.registerCallableModule(
|
|
'RTEventEmitter',
|
|
ReactNativeRTEventEmitter,
|
|
);
|