Skip to content

Commit

Permalink
Convert RCTModernEventEmitter
Browse files Browse the repository at this point in the history
Summary:
# Changelog:
[Internal] -

As in the title.

Differential Revision: D67793108
  • Loading branch information
rshest authored and facebook-github-bot committed Jan 3, 2025
1 parent 15f646d commit 4d9d66e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 49 deletions.

This file was deleted.

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

Expand Down

0 comments on commit 4d9d66e

Please sign in to comment.