Expose receiveEvent as a high level API on UIManager

Summary:
This diff exposes receiveEvent on the UIManager class. This is necessary to support backward compatibility between Fabric and classic RN

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21979687

fbshipit-source-id: 1ec75896687d55e699f79c520e21f05fac368ee6
This commit is contained in:
David Vacca
2020-06-10 22:45:53 -07:00
committed by Facebook GitHub Bot
parent 92630856c6
commit a0baba654e
3 changed files with 18 additions and 0 deletions
@@ -113,4 +113,14 @@ public interface UIManager extends JSIModule, PerformanceCounter {
* @param listener
*/
void removeUIManagerEventListener(UIManagerListener listener);
/**
* This method dispatches events from RN Android code to JS. The delivery of this event will not
* be queued in EventDispatcher class.
*
* @param reactTag tag
* @param eventName name of the event
* @param event parameters
*/
void receiveEvent(int reactTag, String eventName, @Nullable WritableMap event);
}
@@ -946,6 +946,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
doLeftAndRightSwapInRTL);
}
@Override
public void receiveEvent(int reactTag, String eventName, @Nullable WritableMap params) {
EventEmitterWrapper eventEmitter = mMountingManager.getEventEmitter(reactTag);
if (eventEmitter == null) {
@@ -950,4 +950,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
.getNativeViewHierarchyManager()
.resolveView(tag);
}
@Override
public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) {
getReactApplicationContext()
.getJSModule(RCTEventEmitter.class)
.receiveEvent(targetTag, eventName, event);
}
}