diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java deleted file mode 100644 index 056c7dcdf3e215..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.uimanager.events; - -import androidx.annotation.Nullable; -import com.facebook.react.bridge.WritableMap; - -/** - * This is a transitional replacement for RCTEventEmitter that works with Fabric and non-Fabric - * renderers. RCTEventEmitter works with Fabric as well, but there are negative perf implications - * and it should be avoided. - * - *

This interface will *also* be deleted in the distant future and be replaced with a new - * interface that doesn't need the old `receiveEvent` method at all. But for the foreseeable future, - * this is the recommended interface to use for EventEmitters. - */ -public interface RCTModernEventEmitter extends RCTEventEmitter { - void receiveEvent(int surfaceId, int targetTag, String eventName, @Nullable WritableMap event); - - void receiveEvent( - int surfaceId, - int targetTag, - String eventName, - boolean canCoalesceEvent, - int customCoalesceKey, - @Nullable WritableMap event, - @EventCategoryDef int category); - - /** - * @deprecated Dispatch the TouchEvent using {@link EventDispatcher} instead - */ - @Deprecated - void receiveTouches(TouchEvent event); -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.kt new file mode 100644 index 00000000000000..edc6fe567087b2 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.uimanager.events + +import com.facebook.react.bridge.WritableMap + +/** + * This is a transitional replacement for [RCTEventEmitter] that works with Fabric and non-Fabric + * renderers. [RCTEventEmitter] works with Fabric as well, but there are negative perf implications + * and it should be avoided. + * + * This interface will *also* be deleted in the distant future and be replaced with a new interface + * that doesn't need the old `receiveEvent` method at all. But for the foreseeable future, this is + * the recommended interface to use for EventEmitters. + */ +@Suppress("DEPRECATION") +public interface RCTModernEventEmitter : RCTEventEmitter { + public fun receiveEvent(surfaceId: Int, targetTag: Int, eventName: String, event: WritableMap?) + + public fun receiveEvent( + surfaceId: Int, + targetTag: Int, + eventName: String, + canCoalesceEvent: Boolean, + customCoalesceKey: Int, + event: WritableMap?, + @EventCategoryDef category: Int + ) + + @Deprecated("Dispatch the TouchEvent using [EventDispatcher] instead") + public fun receiveTouches(event: TouchEvent) +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.kt index cefbefbfb47270..0aa3c657b08547 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.kt @@ -110,26 +110,20 @@ internal class ReactEventEmitter(private val reactContext: ReactApplicationConte override fun receiveEvent( surfaceId: Int, - targetReactTag: Int, + targetTag: Int, eventName: String, canCoalesceEvent: Boolean, customCoalesceKey: Int, event: WritableMap?, @EventCategoryDef category: Int ) { - @UIManagerType val uiManagerType = getUIManagerType(targetReactTag, surfaceId) + @UIManagerType val uiManagerType = getUIManagerType(targetTag, surfaceId) if (uiManagerType == UIManagerType.FABRIC) { fabricEventEmitter?.receiveEvent( - surfaceId, - targetReactTag, - eventName, - canCoalesceEvent, - customCoalesceKey, - event, - category) + surfaceId, targetTag, eventName, canCoalesceEvent, customCoalesceKey, event, category) } else if (uiManagerType == UIManagerType.DEFAULT) { val defaultEmitter = defaultEventEmitter - @Suppress("DEPRECATION") defaultEmitter?.receiveEvent(targetReactTag, eventName, event) + @Suppress("DEPRECATION") defaultEmitter?.receiveEvent(targetTag, eventName, event) } }