From eedcdc55b5a6db179d1f923fb3f99a37bdc19428 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Fri, 3 Jan 2025 06:13:47 -0800 Subject: [PATCH] '[skip ci] [RN][kotlin] Migrate RCTEventEmitter to Kotlin (#48467) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48467 # Changelog: [Internal] - As in the title. Differential Revision: D67793304' --- .../uimanager/events/RCTEventEmitter.java | 43 ------------------ .../react/uimanager/events/RCTEventEmitter.kt | 44 +++++++++++++++++++ .../uimanager/events/ReactEventEmitter.kt | 4 +- 3 files changed, 46 insertions(+), 45 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.java deleted file mode 100644 index c51ed518ba56e4..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.java +++ /dev/null @@ -1,43 +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.proguard.annotations.DoNotStrip; -import com.facebook.react.bridge.JavaScriptModule; -import com.facebook.react.bridge.WritableArray; -import com.facebook.react.bridge.WritableMap; - -/** - * Paper JS interface to emit events from native to JS. - * - *

Deprecated in favor of RCTModernEventEmitter, which works with both the old and new renderer. - */ -@DoNotStrip -@Deprecated -public interface RCTEventEmitter extends JavaScriptModule { - /** - * @param targetReactTag react tag of the view that receives the event - * @param eventName name of event - * @param event event params - * @deprecated Use RCTModernEventEmitter.receiveEvent instead - */ - @Deprecated - void receiveEvent(int targetReactTag, String eventName, @Nullable WritableMap event); - - /** - * Receive and process touches - * - * @param eventName JS event name - * @param touches active pointers data - * @param changedIndices indices of changed pointers - * @deprecated Dispatch the TouchEvent using {@link EventDispatcher} instead - */ - @Deprecated - void receiveTouches(String eventName, WritableArray touches, WritableArray changedIndices); -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.kt new file mode 100644 index 00000000000000..9ad48ee4a8a69e --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTEventEmitter.kt @@ -0,0 +1,44 @@ +/* + * 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.proguard.annotations.DoNotStripAny +import com.facebook.react.bridge.JavaScriptModule +import com.facebook.react.bridge.WritableArray +import com.facebook.react.bridge.WritableMap + +/** + * Paper JS interface to emit events from native to JS. + * + * Deprecated in favor of [RCTModernEventEmitter], which works with both the old and new renderer. + */ +@DoNotStripAny +@Deprecated("Use [RCTModernEventEmitter] instead") +public interface RCTEventEmitter : JavaScriptModule { + /** + * @param targetTag react tag of the view that receives the event + * @param eventName name of event + * @param event event params + */ + @Deprecated("Use [RCTModernEventEmitter.receiveEvent] instead") + public fun receiveEvent(targetTag: Int, eventName: String, event: WritableMap?) + + /** + * Receive and process touches + * + * @param eventName JS event name + * @param touches active pointers data + * @param changedIndices indices of changed pointers + */ + @Deprecated("Dispatch the TouchEvent using [EventDispatcher] instead") + public fun receiveTouches( + eventName: String, + touches: WritableArray, + changedIndices: WritableArray + ) +} 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 0aa3c657b08547..22b09eedab111d 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 @@ -44,8 +44,8 @@ internal class ReactEventEmitter(private val reactContext: ReactApplicationConte } @Deprecated("Please use RCTModernEventEmitter") - override fun receiveEvent(targetReactTag: Int, eventName: String, event: WritableMap?) { - receiveEvent(-1, targetReactTag, eventName, event) + override fun receiveEvent(targetTag: Int, eventName: String, event: WritableMap?) { + receiveEvent(-1, targetTag, eventName, event) } override fun receiveEvent(