mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate RCTEventEmitter to Kotlin (#48467)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48467 # Changelog: [Internal] - As in the title. Reviewed By: christophpurrer Differential Revision: D67793304 fbshipit-source-id: 39bbdebf8434ad57bab3e1d309915a8132033f5b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d5f33c19cb
commit
d470f39d8a
+3
-3
@@ -31,12 +31,12 @@ public class InteropEventEmitter(private val reactContext: ReactContext) : RCTEv
|
||||
private var eventDispatcherOverride: EventDispatcher? = null
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun receiveEvent(targetReactTag: Int, eventName: String, eventData: WritableMap?) {
|
||||
override fun receiveEvent(targetTag: Int, eventName: String, params: WritableMap?) {
|
||||
val dispatcher: EventDispatcher? =
|
||||
eventDispatcherOverride
|
||||
?: UIManagerHelper.getEventDispatcherForReactTag(reactContext, targetReactTag)
|
||||
?: UIManagerHelper.getEventDispatcherForReactTag(reactContext, targetTag)
|
||||
val surfaceId = UIManagerHelper.getSurfaceId(reactContext)
|
||||
dispatcher?.dispatchEvent(InteropEvent(eventName, eventData, surfaceId, targetReactTag))
|
||||
dispatcher?.dispatchEvent(InteropEvent(eventName, params, surfaceId, targetTag))
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
|
||||
-43
@@ -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.
|
||||
*
|
||||
* <p>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);
|
||||
}
|
||||
+44
@@ -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 params event params
|
||||
*/
|
||||
@Deprecated("Use [RCTModernEventEmitter.receiveEvent] instead")
|
||||
public fun receiveEvent(targetTag: Int, eventName: String, params: 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
|
||||
)
|
||||
}
|
||||
+2
-2
@@ -45,8 +45,8 @@ internal class ReactEventEmitter(private val reactContext: ReactApplicationConte
|
||||
}
|
||||
|
||||
@Deprecated("Please use RCTModernEventEmitter")
|
||||
override fun receiveEvent(targetReactTag: Int, eventName: String, params: WritableMap?) {
|
||||
receiveEvent(-1, targetReactTag, eventName, params)
|
||||
override fun receiveEvent(targetTag: Int, eventName: String, params: WritableMap?) {
|
||||
receiveEvent(-1, targetTag, eventName, params)
|
||||
}
|
||||
|
||||
override fun receiveEvent(
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
|
||||
class FakeRCTEventEmitter : RCTEventEmitter {
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun receiveEvent(targetReactTag: Int, eventName: String, event: WritableMap?) = Unit
|
||||
override fun receiveEvent(targetTag: Int, eventName: String, params: WritableMap?) = Unit
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun receiveTouches(
|
||||
|
||||
Reference in New Issue
Block a user