Skip to content

Commit

Permalink
Migrate RCTEventEmitter to Kotlin (#48467)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #48467

# Changelog:
[Internal] -

As in the title.

Differential Revision: D67793304
  • Loading branch information
rshest authored and facebook-github-bot committed Jan 4, 2025
1 parent 6d7751a commit c872b67
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c872b67

Please sign in to comment.