21
import getListener from './ReactNativeGetListener';
22
import {runEventsInBatch} from './legacy-events/EventBatching';
23
24
+import {RawEventEmitter} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
25
+
26
export {getListener, registrationNameModules as registrationNames};
27
28
/**
75
76
export function dispatchEvent(
77
target: null | Object,
76
- topLevelType: TopLevelType,
78
+ topLevelType: RNTopLevelEventType,
79
nativeEvent: AnyNativeEvent,
80
) {
81
const targetFiber = (target: null | Fiber);
90
}
91
92
batchedUpdates(function() {
93
+ // Emit event to the RawEventEmitter. This is an unused-by-default EventEmitter
94
+ // that can be used to instrument event performance monitoring (primarily - could be useful
95
+ // for other things too).
96
+ //
97
+ // NOTE: this merely emits events into the EventEmitter below.
98
+ // If *you* do not add listeners to the `RawEventEmitter`,
99
+ // then all of these emitted events will just blackhole and are no-ops.
100
+ // It is available (although not officially supported... yet) if you want to collect
101
+ // perf data on event latency in your application, and could also be useful for debugging
102
+ // low-level events issues.
103
+ //
104
+ // If you do not have any event perf monitoring and are extremely concerned about event perf,
105
+ // it is safe to disable these "emit" statements; it will prevent checking the size of
106
+ // an empty array twice and prevent two no-ops. Practically the overhead is so low that
107
+ // we don't think it's worth thinking about in prod; your perf issues probably lie elsewhere.
108
+ //
109
+ // We emit two events here: one for listeners to this specific event,
110
+ // and one for the catchall listener '*', for any listeners that want
111
+ // to be notified for all events.
112
+ // Note that extracted events are *not* emitted,
113
+ // only events that have a 1:1 mapping with a native event, at least for now.
114
+ const event = {eventName: topLevelType, nativeEvent};
115
+ RawEventEmitter.emit(topLevelType, event);
116
+ RawEventEmitter.emit('*', event);
117
+
118
// Heritage plugin event system
119
runExtractedPluginEventsInBatch(
120
topLevelType,