Create V2 EventEmitter (ModernEventEmitter) interface that surfaceId can be passed into

Summary:
Create V2 EventEmitter that surfaceId can be passed into, with a backwards-compat layer, and some debug-only logging to help assist with migration.

Changelog: [Changed][Android] RCTEventEmitter has been deprecated in favor of RCTModernEventEmitter for optimal Fabric support; RCTEventEmitter will continue to work in Fabric, but there are minor perf implications.

Reviewed By: mdvacca

Differential Revision: D26027104

fbshipit-source-id: 784ca092bbc88d19c82f6c42537c34460d96de86
This commit is contained in:
Joshua Gross
2021-01-22 19:29:00 -08:00
committed by Facebook GitHub Bot
parent 8357b39908
commit 2fbbdbb2ce
8 changed files with 111 additions and 11 deletions
@@ -87,6 +87,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
@ReactModule(name = UIManagerModule.NAME)
public class UIManagerModule extends ReactContextBaseJavaModule
implements OnBatchCompleteListener, LifecycleEventListener, UIManager {
public static final String TAG = UIManagerModule.class.getSimpleName();
/** Enables lazy discovery of a specific {@link ViewManager} by its name. */
public interface ViewManagerResolver {
@@ -993,9 +994,16 @@ public class UIManagerModule extends ReactContextBaseJavaModule
}
@Override
public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) {
public void receiveEvent(int reactTag, String eventName, @Nullable WritableMap event) {
receiveEvent(-1, reactTag, eventName, event);
}
@Override
public void receiveEvent(
int surfaceId, int reactTag, String eventName, @Nullable WritableMap event) {
assert ViewUtil.getUIManagerType(reactTag) == DEFAULT;
getReactApplicationContext()
.getJSModule(RCTEventEmitter.class)
.receiveEvent(targetTag, eventName, event);
.receiveEvent(reactTag, eventName, event);
}
}