forked from facebook/react
/
ReactFabricEventEmitter.js
53 lines (48 loc) · 1.56 KB
/
ReactFabricEventEmitter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {Fiber} from 'react-reconciler/src/ReactFiber';
import {PLUGIN_EVENT_SYSTEM} from 'legacy-events/EventSystemFlags';
import {
getListener,
runExtractedPluginEventsInBatch,
} from 'legacy-events/EventPluginHub';
import {registrationNameModules} from 'legacy-events/EventPluginRegistry';
import {batchedUpdates} from 'legacy-events/ReactGenericBatching';
import type {AnyNativeEvent} from 'legacy-events/PluginModuleType';
import {enableFlareAPI} from 'shared/ReactFeatureFlags';
import type {TopLevelType} from 'legacy-events/TopLevelEventTypes';
import {dispatchEventForResponderEventSystem} from './ReactFabricEventResponderSystem';
export {getListener, registrationNameModules as registrationNames};
export function dispatchEvent(
target: null | Object,
topLevelType: TopLevelType,
nativeEvent: AnyNativeEvent,
) {
const targetFiber = (target: null | Fiber);
if (enableFlareAPI) {
// React Flare event system
dispatchEventForResponderEventSystem(
(topLevelType: any),
target,
(nativeEvent: any),
);
}
batchedUpdates(function() {
// Heritage plugin event system
runExtractedPluginEventsInBatch(
topLevelType,
targetFiber,
nativeEvent,
nativeEvent.target,
PLUGIN_EVENT_SYSTEM,
);
});
// React Native doesn't use ReactControlledComponent but if it did, here's
// where it would do it.
}