Skip to content

Commit bd85bf7

Browse files
authored
Make ReanimatedEventDispatcher a class and not an object (#2203)
## Description This PR changes `ReanimatedEventDispatcher` from `object` to `class` and makes it a field in the `RNGestureHandlerModule`. This way the old Reanimated module shouldn't be preserved during reload, as the dispatcher will be dropped alongside everything else.
1 parent 1d31bbb commit bd85bf7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.swmansion.gesturehandler
33
import com.facebook.react.bridge.ReactContext
44
import com.facebook.react.uimanager.events.Event
55

6-
object ReanimatedEventDispatcher {
6+
class ReanimatedEventDispatcher {
77
fun <T : Event<T>>sendEvent(event: T, reactApplicationContext: ReactContext) {
88
// no-op
99
}

android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.facebook.react.bridge.ReactContext
44
import com.facebook.react.uimanager.events.Event
55
import com.swmansion.reanimated.ReanimatedModule
66

7-
object ReanimatedEventDispatcher {
7+
class ReanimatedEventDispatcher {
88
private var reanimatedModule: ReanimatedModule? = null
99

1010
fun <T : Event<T>>sendEvent(event: T, reactApplicationContext: ReactContext) {

android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
346346
val registry: RNGestureHandlerRegistry = RNGestureHandlerRegistry()
347347
private val interactionManager = RNGestureHandlerInteractionManager()
348348
private val roots: MutableList<RNGestureHandlerRootHelper> = ArrayList()
349-
private val enqueuedRootViewInit: MutableList<Int> = ArrayList()
349+
private val reanimatedEventDispatcher = ReanimatedEventDispatcher()
350350
override fun getName() = MODULE_NAME
351351

352352
@ReactMethod
@@ -593,7 +593,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
593593
// Delivers the event to Reanimated.
594594
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
595595
// Send event directly to Reanimated
596-
ReanimatedEventDispatcher.sendEvent(event, reactApplicationContext)
596+
reanimatedEventDispatcher.sendEvent(event, reactApplicationContext)
597597
} else {
598598
// In the old architecture, Reanimated subscribes for specific direct events.
599599
sendEventForDirectEvent(event)

0 commit comments

Comments
 (0)