Skip to content

Commit 3fb11ee

Browse files
authored
React Native: Touch Instrumentation Interface (#21024)
1 parent 119736b commit 3fb11ee

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,21 @@ function printTouchBank(): string {
184184
return printed;
185185
}
186186

187+
let instrumentationCallback: ?(string, TouchEvent) => void;
188+
187189
const ResponderTouchHistoryStore = {
190+
/**
191+
* Registers a listener which can be used to instrument every touch event.
192+
*/
193+
instrument(callback: (string, TouchEvent) => void): void {
194+
instrumentationCallback = callback;
195+
},
196+
188197
recordTouchTrack(topLevelType: string, nativeEvent: TouchEvent): void {
198+
if (instrumentationCallback != null) {
199+
instrumentationCallback(topLevelType, nativeEvent);
200+
}
201+
189202
if (isMoveish(topLevelType)) {
190203
nativeEvent.changedTouches.forEach(recordTouchMove);
191204
} else if (isStartish(topLevelType)) {

0 commit comments

Comments
 (0)