Support RCTModernEventEmitter+RCTEventEmitter in ShowEvent Event class

Summary:
Support RCTModernEventEmitter+RCTEventEmitter in an Event class(es). This improves perf in Fabric. Migrate any constructor callsites to the new constructor and deprecate the previous one.

Changelog: [Internal]

Reviewed By: PeteTheHeat, mdvacca

Differential Revision: D26056723

fbshipit-source-id: c20183a4a1189f13b15a138968937080888a200b
This commit is contained in:
Joshua Gross
2021-01-28 14:07:30 -08:00
committed by Facebook GitHub Bot
parent 1575e7ffe3
commit db5bc2f766
2 changed files with 14 additions and 5 deletions
@@ -121,7 +121,8 @@ public class ReactModalHostManager extends ViewGroupManager<ReactModalHostView>
new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
dispatcher.dispatchEvent(new ShowEvent(view.getId()));
dispatcher.dispatchEvent(
new ShowEvent(UIManagerHelper.getSurfaceId(reactContext), view.getId()));
}
});
view.setEventDispatcher(dispatcher);
@@ -7,16 +7,23 @@
package com.facebook.react.views.modal;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.RCTEventEmitter;
/** {@link Event} for showing a Dialog. */
/* package */ class ShowEvent extends Event<ShowEvent> {
public static final String EVENT_NAME = "topShow";
@Deprecated
protected ShowEvent(int viewTag) {
super(viewTag);
this(-1, viewTag);
}
protected ShowEvent(int surfaceId, int viewTag) {
super(surfaceId, viewTag);
}
@Override
@@ -24,8 +31,9 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
return EVENT_NAME;
}
@Nullable
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), null);
protected WritableMap getEventData() {
return Arguments.createMap();
}
}