Skip to content

Refactor RNGestureHandlerModule on android#3489

Merged
j-piasecki merged 7 commits into
mainfrom
@jpiasecki/refactor-module-android
May 26, 2025
Merged

Refactor RNGestureHandlerModule on android#3489
j-piasecki merged 7 commits into
mainfrom
@jpiasecki/refactor-module-android

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

Description

  • simplifies RNGestureHandlerRootHelper a bit
  • moves logic related to sending events to a separate class
  • moves logic related to resolving handler factories to a separate class

Test plan

Example & FabricExample apps

Copy link
Copy Markdown
Collaborator

@m-bert m-bert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I think in some places we can switch from using if in favor of when 😅

@j-piasecki j-piasecki force-pushed the @jpiasecki/refactor-module-android branch from ce41b6f to 0e36025 Compare May 26, 2025 06:10
@j-piasecki j-piasecki requested a review from m-bert May 26, 2025 07:43
@j-piasecki j-piasecki merged commit 3a93c6e into main May 26, 2025
4 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/refactor-module-android branch May 26, 2025 12:21
j-piasecki added a commit that referenced this pull request May 27, 2025
## Description

Depends on
#3489

On Android, `GestureHandler` was a generic class specialized by the
concrete type of the handler. The only place it was used was `applySelf`
method, which allowed for inherited methods to return the concrete
handler:

```
tapHandler.setEnabled(true) // returns TapGestureHandler instead of GestureHandler
```

...but we don't use this pattern anywhere. It made much more sense in
Java, than it does in Kotlin, where we can simply use `apply`, `let`,
etc. when there's a need to do multiple operations on the same object.
Now, it simply makes the logic dealing with gesture handlers more
complicated as it also needs to keep track of the generic type, which in
most cases is `*` so it doesn't give us more type safety.

This PR makes it so that the base `GestureHandler` class is no longer
generic, which should make life easier when dealing with non-concrete
gesture handlers in the future.

## Test plan

Build example apps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants