mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Shortcut emitDeviceEvent in bridgeless (#44574)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44574 `emitDeviceEvent` is frequently used for perf-critical operations such as sending network responses from native to JS. We don't need to go through JavaScriptModule Proxy (which is missing caching in bridgeless) and instead can immediately invoke the callable JS module. Changelog: [Internal] Reviewed By: RSNara Differential Revision: D57329165 fbshipit-source-id: 6506a7afb522b672a1f3dc7d348c9b80e6734225
This commit is contained in:
committed by
Facebook GitHub Bot
parent
95f7a5c597
commit
d0bb396ddb
+9
@@ -134,6 +134,8 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
||||
&& mInteropModuleRegistry.shouldReturnInteropModule(jsInterface)) {
|
||||
return mInteropModuleRegistry.getInteropModule(jsInterface);
|
||||
}
|
||||
|
||||
// TODO T189052462: ReactContext caches JavaScriptModule instances
|
||||
JavaScriptModule interfaceProxy =
|
||||
(JavaScriptModule)
|
||||
Proxy.newProxyInstance(
|
||||
@@ -143,6 +145,13 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
||||
return (T) interfaceProxy;
|
||||
}
|
||||
|
||||
/** Shortcut RCTDeviceEventEmitter.emit since it's frequently used */
|
||||
@Override
|
||||
public void emitDeviceEvent(String eventName, @Nullable Object args) {
|
||||
mReactHost.callFunctionOnModule(
|
||||
"RCTDeviceEventEmitter", "emit", Arguments.fromJavaArgs(new Object[] {args}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends NativeModule> boolean hasNativeModule(Class<T> nativeModuleInterface) {
|
||||
return mReactHost.hasNativeModule(nativeModuleInterface);
|
||||
|
||||
Reference in New Issue
Block a user