Skip to content

Commit 55671c0

Browse files
authored
[0.76] Undo breaking change on UIManager eventDispatcher accessor (#47090)
Summary: Whe migrating this interface to Kotlin we've subtly introduced a breaking change which is causing a lot of breakages in the ecosystem. This is forcing users to do: ``` // Before reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher // After reactContext.getNativeModule(UIManagerModule::class.java)!!.getEventDispatcher() ``` This reverts this breaking change. Plus the method had a generic parameters which was completely unnecessary so I'm removing it. Changelog: [Android] [Fixed] - Undo breaking change on UIManager eventDispatcher accessor Reviewed By: cipolleschi Differential Revision: D64533594
1 parent ce16206 commit 55671c0

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.annotation.AnyThread
1212
import androidx.annotation.UiThread
1313
import com.facebook.infer.annotation.ThreadConfined
1414
import com.facebook.react.common.annotations.UnstableReactNativeAPI
15+
import com.facebook.react.uimanager.events.EventDispatcher
1516

1617
@OptIn(UnstableReactNativeAPI::class)
1718
public interface UIManager : PerformanceCounter {
@@ -78,7 +79,7 @@ public interface UIManager : PerformanceCounter {
7879
public fun dispatchCommand(reactTag: Int, commandId: String, commandArgs: ReadableArray?)
7980

8081
/** @return the [EventDispatcher] object that is used by this class. */
81-
public fun <T> getEventDispatcher(): T
82+
public val eventDispatcher: EventDispatcher
8283

8384
/**
8485
* Used by native animated module to bypass the process of updating the values through the shadow

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,6 @@ public void onHostResume() {
10211021

10221022
@Override
10231023
@NonNull
1024-
@SuppressWarnings("unchecked")
10251024
public EventDispatcher getEventDispatcher() {
10261025
return mEventDispatcher;
10271026
}

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class RootViewTest {
9292
val eventEmitterModuleMock = mock(RCTEventEmitter::class.java)
9393
whenever(catalystInstanceMock.getNativeModule(UIManagerModule::class.java))
9494
.thenReturn(uiManager)
95-
whenever(uiManager.getEventDispatcher()).thenReturn(eventDispatcher)
95+
whenever(uiManager.eventDispatcher).thenReturn(eventDispatcher)
9696

9797
// RootView IDs is React Native follow the 11, 21, 31, ... progression.
9898
val rootViewId = 11

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class NativeAnimatedNodeTraversalTest {
8686

8787
uiManagerMock = mock(UIManagerModule::class.java)
8888
eventDispatcherMock = mock(EventDispatcher::class.java)
89-
whenever(uiManagerMock.getEventDispatcher()).thenAnswer { eventDispatcherMock }
89+
whenever(uiManagerMock.eventDispatcher).thenAnswer { eventDispatcherMock }
9090
whenever(uiManagerMock.constants).thenAnswer {
9191
mapOf("customDirectEventTypes" to emptyMap<Any, Any>())
9292
}

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ class TouchEventDispatchTest {
488488
spy(FabricUIManager(reactContext, viewManagerRegistry, batchEventDispatchedListener))
489489
uiManager.initialize()
490490

491-
eventDispatcher = uiManager.getEventDispatcher()
491+
eventDispatcher = uiManager.eventDispatcher
492492

493493
// Ignore scheduled choreographer work
494494
val reactChoreographerMock = mock(ReactChoreographer::class.java)

packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.facebook.react.bridge.UIManagerListener
1717
import com.facebook.react.bridge.WritableMap
1818
import com.facebook.react.common.annotations.UnstableReactNativeAPI
1919
import com.facebook.react.fabric.interop.UIBlockViewResolver
20+
import com.facebook.react.uimanager.events.EventDispatcher
2021

2122
@OptIn(UnstableReactNativeAPI::class)
2223
class FakeUIManager : UIManager, UIBlockViewResolver {
@@ -65,7 +66,10 @@ class FakeUIManager : UIManager, UIBlockViewResolver {
6566
error("Not yet implemented")
6667
}
6768

68-
override fun <T : Any?> getEventDispatcher(): T {
69+
override val eventDispatcher: EventDispatcher
70+
get() = TODO("Not yet implemented")
71+
72+
fun <T : Any?> getEventDispatcher(): T {
6973
error("Not yet implemented")
7074
}
7175

0 commit comments

Comments
 (0)