-
-
Notifications
You must be signed in to change notification settings - Fork 1k
State Manager #3880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
State Manager #3880
Conversation
| declare const globalThis: { | ||
| _setGestureStateSync?: (handlerTag: number, state: State) => void; | ||
| _setGestureStateAsync?: (handlerTag: number, state: State) => void; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be added as global.d.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that leak those definitions outside of the library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you might be right. As far as I remember we did it with @tjzel to overcome some TS problems, but this may be a better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe get rid of the file you linked with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't exist on next 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We made the global.d.ts file with @m-bert so it's read only when developing the package and it's not exposed to the library consumer. If you leave this declare cost here then it will leak to the user.
You should move these types to global.d.ts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done in 30c8c82
packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts
Outdated
Show resolved
Hide resolved
j-piasecki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please wait for the comments to be resolved.
## Description Restores `handlerTag` to the update and state change events. This information will be necessary to use the new state manager added in #3880. ## Test plan Verify that `handlerTag` exists on events
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I'm a fan of .begin(tag), something along .for(tag).begin() in my opinion fits better, but given that it is relatively new feature maybe simpler API will be better.
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Hmm, Edit: Maybe let's stick to the current approach, and we will see what feedback we get on that. WDYT? |
To be honest I prefer the simpler approach, but if you both want it to be |
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it might be an overkill, but since we have two different implementations, maybe we could introduce an interface to make sure that they both meet the same criteria? This probably won't change, but it won't hurt us to have one. Let me know what you think.
| setGestureState(handlerTag, State.BEGAN); | ||
| }; | ||
| export const GestureStateManager = { | ||
| begin(handlerTag: number): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| begin(handlerTag: number): void { | |
| begin(handlerTag: number) { |
I don't think we need those type declarations here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: as we discussed in the office, I misunderstood. Good idea, added interface in 7fa4cfa |
m-bert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merry Christmas 🎄🎅
Description
Implements V3 State Manager, to manually manage gestures.
Test plan
Tested on the following example, the long press should activate instantely, while the minDuration is extremely big.
Details