React Native: Touch Instrumentation Interface (#21024)

This commit is contained in:
Timothy Yung
2021-03-17 13:46:43 -07:00
committed by GitHub
parent 119736b1c2
commit 3fb11eed9a

View File

@@ -184,8 +184,21 @@ function printTouchBank(): string {
return printed;
}
let instrumentationCallback: ?(string, TouchEvent) => void;
const ResponderTouchHistoryStore = {
/**
* Registers a listener which can be used to instrument every touch event.
*/
instrument(callback: (string, TouchEvent) => void): void {
instrumentationCallback = callback;
},
recordTouchTrack(topLevelType: string, nativeEvent: TouchEvent): void {
if (instrumentationCallback != null) {
instrumentationCallback(topLevelType, nativeEvent);
}
if (isMoveish(topLevelType)) {
nativeEvent.changedTouches.forEach(recordTouchMove);
} else if (isStartish(topLevelType)) {