Skip to content

Commit e7e0c3e

Browse files
javachezoontek
authored andcommitted
Remove legacy event dispatching logic (facebook#55802)
Summary: Pull Request resolved: facebook#55802 Remove legacy Paper event emitters and deprecated methods (`receiveTouches`). InteropEvent still functions as before otherwise, and I've kept the `event.dispatch` API (although I believe events without a surface ID are dropped later in the pipeline?) Changelog: [Android][Removed] Removed Paper-specific event dispatching methods. Reviewed By: cortinico Differential Revision: D91320248 fbshipit-source-id: a3228593c72a4286f7aac781d446fc3b0b1bd4ff
1 parent 917ac07 commit e7e0c3e

15 files changed

Lines changed: 35 additions & 663 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4846,19 +4846,23 @@ public final class com/facebook/react/uimanager/events/NativeGestureUtil {
48464846

48474847
public abstract interface class com/facebook/react/uimanager/events/RCTEventEmitter : com/facebook/react/bridge/JavaScriptModule {
48484848
public abstract fun receiveEvent (ILjava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
4849-
public abstract fun receiveTouches (Ljava/lang/String;Lcom/facebook/react/bridge/WritableArray;Lcom/facebook/react/bridge/WritableArray;)V
48504849
}
48514850

48524851
public abstract interface class com/facebook/react/uimanager/events/RCTModernEventEmitter : com/facebook/react/uimanager/events/RCTEventEmitter {
48534852
public abstract fun receiveEvent (IILjava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
48544853
public abstract fun receiveEvent (IILjava/lang/String;ZILcom/facebook/react/bridge/WritableMap;I)V
4854+
public abstract fun receiveEvent (ILjava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
4855+
}
4856+
4857+
public final class com/facebook/react/uimanager/events/RCTModernEventEmitter$DefaultImpls {
4858+
public static fun receiveEvent (Lcom/facebook/react/uimanager/events/RCTModernEventEmitter;IILjava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
4859+
public static fun receiveEvent (Lcom/facebook/react/uimanager/events/RCTModernEventEmitter;ILjava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
48554860
}
48564861

48574862
public final class com/facebook/react/uimanager/events/TouchEvent : com/facebook/react/uimanager/events/Event {
48584863
public static final field Companion Lcom/facebook/react/uimanager/events/TouchEvent$Companion;
48594864
public static final field UNSET J
48604865
public fun canCoalesce ()Z
4861-
public fun dispatch (Lcom/facebook/react/uimanager/events/RCTEventEmitter;)V
48624866
public fun dispatchModern (Lcom/facebook/react/uimanager/events/RCTModernEventEmitter;)V
48634867
public fun getCoalescingKey ()S
48644868
public fun getEventCategory ()I

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.kt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.facebook.react.bridge.ReadableArray
1111
import com.facebook.react.bridge.ReadableMap
1212
import com.facebook.react.bridge.ReadableType
1313
import com.facebook.react.bridge.UnexpectedNativeTypeException
14-
import com.facebook.react.bridge.WritableArray
1514
import com.facebook.react.bridge.WritableMap
1615
import com.facebook.react.uimanager.events.EventCategoryDef
1716
import com.facebook.react.uimanager.events.RCTModernEventEmitter
@@ -23,31 +22,6 @@ internal class EventAnimationDriver(
2322
private val eventPath: List<String>,
2423
@JvmField internal var valueNode: ValueAnimatedNode,
2524
) : RCTModernEventEmitter {
26-
@Deprecated(
27-
"Deprecated in Java",
28-
ReplaceWith("receiveEvent(surfaceId, targetTag, eventName, params)"),
29-
)
30-
override fun receiveEvent(targetTag: Int, eventName: String, params: WritableMap?) =
31-
receiveEvent(-1, targetTag, eventName, params)
32-
33-
override fun receiveEvent(
34-
surfaceId: Int,
35-
targetTag: Int,
36-
eventName: String,
37-
params: WritableMap?,
38-
) =
39-
// We assume this event can't be coalesced. `customCoalesceKey` has no meaning in Fabric.
40-
receiveEvent(surfaceId, targetTag, eventName, false, 0, params, EventCategoryDef.UNSPECIFIED)
41-
42-
@Deprecated("Deprecated in Java")
43-
override fun receiveTouches(
44-
eventName: String,
45-
touches: WritableArray,
46-
changedIndices: WritableArray,
47-
) {
48-
throw UnsupportedOperationException("receiveTouches is not support by native animated events")
49-
}
50-
5125
override fun receiveEvent(
5226
surfaceId: Int,
5327
targetTag: Int,

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,13 @@
77

88
package com.facebook.react.fabric.events
99

10-
import com.facebook.react.bridge.WritableArray
1110
import com.facebook.react.bridge.WritableMap
1211
import com.facebook.react.fabric.FabricUIManager
13-
import com.facebook.react.uimanager.common.ViewUtil
1412
import com.facebook.react.uimanager.events.EventCategoryDef
1513
import com.facebook.react.uimanager.events.RCTModernEventEmitter
1614
import com.facebook.systrace.Systrace
1715

1816
internal class FabricEventEmitter(private val uiManager: FabricUIManager) : RCTModernEventEmitter {
19-
@Deprecated(
20-
"Use receiveEvent with surfaceId instead.",
21-
ReplaceWith("receiveEvent(surfaceId, targetTag, eventName, params)"),
22-
)
23-
override fun receiveEvent(targetTag: Int, eventName: String, params: WritableMap?): Unit {
24-
receiveEvent(ViewUtil.NO_SURFACE_ID, targetTag, eventName, params)
25-
}
26-
27-
override fun receiveEvent(
28-
surfaceId: Int,
29-
targetTag: Int,
30-
eventName: String,
31-
params: WritableMap?,
32-
) {
33-
receiveEvent(surfaceId, targetTag, eventName, false, 0, params, EventCategoryDef.UNSPECIFIED)
34-
}
35-
3617
override fun receiveEvent(
3718
surfaceId: Int,
3819
targetTag: Int,
@@ -49,14 +30,4 @@ internal class FabricEventEmitter(private val uiManager: FabricUIManager) : RCTM
4930
Systrace.endSection(Systrace.TRACE_TAG_REACT)
5031
}
5132
}
52-
53-
/** Touches are dispatched by [receiveTouches] */
54-
@Deprecated("Deprecated in Java")
55-
override fun receiveTouches(
56-
eventName: String,
57-
touches: WritableArray,
58-
changedIndices: WritableArray,
59-
): Unit {
60-
throw UnsupportedOperationException("EventEmitter#receiveTouches is not supported by Fabric")
61-
}
6233
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/interop/InteropEventEmitter.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package com.facebook.react.internal.interop
1111

1212
import com.facebook.react.bridge.ReactContext
13-
import com.facebook.react.bridge.WritableArray
1413
import com.facebook.react.bridge.WritableMap
1514
import com.facebook.react.common.annotations.VisibleForTesting
1615
import com.facebook.react.common.annotations.internal.InteropLegacyArchitecture
@@ -36,24 +35,11 @@ internal class InteropEventEmitter(private val reactContext: ReactContext) : RCT
3635

3736
@Deprecated("Deprecated in Java")
3837
override fun receiveEvent(targetTag: Int, eventName: String, params: WritableMap?) {
39-
val dispatcher: EventDispatcher? =
40-
eventDispatcherOverride
41-
?: UIManagerHelper.getEventDispatcherForReactTag(reactContext, targetTag)
38+
val dispatcher = eventDispatcherOverride ?: UIManagerHelper.getEventDispatcher(reactContext)
4239
val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
4340
dispatcher?.dispatchEvent(InteropEvent(eventName, params, surfaceId, targetTag))
4441
}
4542

46-
@Deprecated("Deprecated in Java")
47-
override fun receiveTouches(
48-
eventName: String,
49-
touches: WritableArray,
50-
changedIndices: WritableArray,
51-
) {
52-
throw UnsupportedOperationException(
53-
"EventEmitter#receiveTouches is not supported by the Fabric Interop Layer"
54-
)
55-
}
56-
5743
@VisibleForTesting
5844
fun overrideEventDispatcher(eventDispatcherOverride: EventDispatcher?) {
5945
this.eventDispatcherOverride = eventDispatcherOverride

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import com.facebook.react.module.annotations.ReactModule;
4545
import com.facebook.react.uimanager.common.ViewUtil;
4646
import com.facebook.react.uimanager.events.EventDispatcher;
47-
import com.facebook.react.uimanager.events.EventDispatcherImpl;
4847
import com.facebook.react.uimanager.events.RCTEventEmitter;
4948
import com.facebook.react.uimanager.internal.LegacyArchitectureShadowNodeLogger;
5049
import com.facebook.systrace.Systrace;
@@ -107,7 +106,6 @@ public interface CustomEventNamesResolver {
107106
private static final boolean DEBUG =
108107
PrinterHolder.getPrinter().shouldDisplayLogMessage(ReactDebugOverlayTags.UI_MANAGER);
109108

110-
private final EventDispatcher mEventDispatcher;
111109
private final Map<String, Object> mModuleConstants;
112110
private final Map<String, Object> mCustomDirectEvents;
113111
private final ViewManagerRegistry mViewManagerRegistry;
@@ -121,11 +119,9 @@ public UIManagerModule(
121119
int minTimeLeftInFrameForNonBatchedOperationMs) {
122120
super(reactContext);
123121
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
124-
mEventDispatcher = new EventDispatcherImpl(reactContext);
125122
mModuleConstants = createConstants(viewManagerResolver);
126123
mCustomDirectEvents = UIManagerModuleConstants.directEventTypeConstants;
127124
mViewManagerRegistry = new ViewManagerRegistry(viewManagerResolver);
128-
129125
reactContext.addLifecycleEventListener(this);
130126
}
131127

@@ -135,11 +131,9 @@ public UIManagerModule(
135131
int minTimeLeftInFrameForNonBatchedOperationMs) {
136132
super(reactContext);
137133
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
138-
mEventDispatcher = new EventDispatcherImpl(reactContext);
139134
mCustomDirectEvents = MapBuilder.newHashMap();
140135
mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
141136
mViewManagerRegistry = new ViewManagerRegistry(viewManagersList);
142-
143137
if (ReactBuildConfig.DEBUG) {
144138
for (ViewManager<?, ?> viewManager : viewManagersList) {
145139
LegacyArchitectureShadowNodeLogger.assertUnsupportedViewManager(
@@ -178,7 +172,6 @@ public void onHostDestroy() {}
178172
@Override
179173
public void invalidate() {
180174
super.invalidate();
181-
mEventDispatcher.onCatalystInstanceDestroyed();
182175

183176
ReactApplicationContext reactApplicationContext = getReactApplicationContext();
184177
reactApplicationContext.unregisterComponentCallbacks(mMemoryTrimCallback);
@@ -571,7 +564,7 @@ public void configureNextLayoutAnimation(ReadableMap config, Callback success, C
571564

572565
@Override
573566
public EventDispatcher getEventDispatcher() {
574-
return mEventDispatcher;
567+
return null;
575568
}
576569

577570
@ReactMethod

0 commit comments

Comments
 (0)