1 | import { ValueOf } from '../typeUtils';
|
2 | import { Gestures } from '../RNGestureHandlerModule.web';
|
3 |
|
4 | const gestures: Record<number, InstanceType<ValueOf<typeof Gestures>>> = {};
|
5 |
|
6 | export function getHandler(tag: number) {
|
7 | if (tag in gestures) return gestures[tag];
|
8 |
|
9 | throw new Error(`No handler for tag ${tag}`);
|
10 | }
|
11 |
|
12 | export function createGestureHandler(
|
13 | handlerTag: number,
|
14 | handler: InstanceType<ValueOf<typeof Gestures>>
|
15 | ) {
|
16 | if (handlerTag in gestures) {
|
17 | throw new Error(`Handler with tag ${handlerTag} already exists`);
|
18 | }
|
19 | gestures[handlerTag] = handler;
|
20 |
|
21 | gestures[handlerTag].handlerTag = handlerTag;
|
22 | }
|
23 |
|
24 | export function dropGestureHandler(handlerTag: number) {
|
25 | getHandler(handlerTag).destroy();
|
26 |
|
27 | delete gestures[handlerTag];
|
28 | }
|
29 |
|
30 | export function getNodes() {
|
31 | return { ...gestures };
|
32 | }
|