mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Force ReactEventEmitter to use RCTEventEmitter as default event emitter class
Summary: This diff forces ReactEventEmitter to use RCTEventEmitter as default event emitter class. This is necessary because of T54134149. This is a temporary fix until we find the root cause of T54134149 Reviewed By: JoshuaGross Differential Revision: D17422611 fbshipit-source-id: 159b216434c79466427b7b1a2b0f71f466b0f606
This commit is contained in:
committed by
Facebook Github Bot
parent
ce48896e99
commit
315759e1fc
@@ -102,7 +102,7 @@ public class EventDispatcher implements LifecycleEventListener {
|
||||
public EventDispatcher(ReactApplicationContext reactContext) {
|
||||
mReactContext = reactContext;
|
||||
mReactContext.addLifecycleEventListener(this);
|
||||
mReactEventEmitter = new ReactEventEmitter();
|
||||
mReactEventEmitter = new ReactEventEmitter(mReactContext);
|
||||
}
|
||||
|
||||
/** Sends the given Event to JS, coalescing eligible events if JS is backed up. */
|
||||
|
||||
+14
-2
@@ -10,7 +10,9 @@ import static com.facebook.react.uimanager.events.TouchesHelper.TARGET_KEY;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
@@ -18,9 +20,15 @@ import com.facebook.react.uimanager.common.ViewUtil;
|
||||
|
||||
public class ReactEventEmitter implements RCTEventEmitter {
|
||||
|
||||
private static final String TAG = ReactEventEmitter.class.getSimpleName();
|
||||
|
||||
private final SparseArray<RCTEventEmitter> mEventEmitters = new SparseArray<>();
|
||||
|
||||
public ReactEventEmitter() {}
|
||||
private final ReactApplicationContext mReactContext;
|
||||
|
||||
public ReactEventEmitter(ReactApplicationContext reactContext) {
|
||||
mReactContext = reactContext;
|
||||
}
|
||||
|
||||
public void register(@UIManagerType int uiManagerType, RCTEventEmitter eventEmitter) {
|
||||
mEventEmitters.put(uiManagerType, eventEmitter);
|
||||
@@ -49,7 +57,11 @@ public class ReactEventEmitter implements RCTEventEmitter {
|
||||
int type = ViewUtil.getUIManagerType(reactTag);
|
||||
RCTEventEmitter eventEmitter = mEventEmitters.get(type);
|
||||
if (eventEmitter == null) {
|
||||
throw new RuntimeException("Unable to find event emitter for type: " + type);
|
||||
// TODO T54145494: Refactor RN Event Emitter system to make sure reactTags are always managed
|
||||
// by RN
|
||||
FLog.i(
|
||||
TAG, "Unable to find event emitter for reactTag: %d - uiManagerType: %d", reactTag, type);
|
||||
eventEmitter = mReactContext.getJSModule(RCTEventEmitter.class);
|
||||
}
|
||||
return eventEmitter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user