Add getNativeModule(String) to ReactContext interface (#44851)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44851 This method is available on the (deprecated) CatalystInstance interface, but not on ReactContext, even though it is trivially supported. Changelog: [Android][Added] - Added getNativeModule(name) to ReactContext Reviewed By: cortinico Differential Revision: D58355135 fbshipit-source-id: 0cc76bb2da2b49510dc626cb8b3a3e93db5a16b0
This commit is contained in:
Родитель
e94852ff28
Коммит
fdb2427a86
|
@ -557,6 +557,7 @@ public class com/facebook/react/bridge/BridgeReactContext : com/facebook/react/b
|
|||
public fun getJSCallInvokerHolder ()Lcom/facebook/react/turbomodule/core/interfaces/CallInvokerHolder;
|
||||
public fun getJSModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/JavaScriptModule;
|
||||
public fun getNativeModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/NativeModule;
|
||||
public fun getNativeModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule;
|
||||
public fun getNativeModules ()Ljava/util/Collection;
|
||||
public fun getSourceURL ()Ljava/lang/String;
|
||||
public fun handleException (Ljava/lang/Exception;)V
|
||||
|
@ -1106,6 +1107,7 @@ public abstract class com/facebook/react/bridge/ReactContext : android/content/C
|
|||
public abstract fun getJavaScriptContextHolder ()Lcom/facebook/react/bridge/JavaScriptContextHolder;
|
||||
public fun getLifecycleState ()Lcom/facebook/react/common/LifecycleState;
|
||||
public abstract fun getNativeModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/NativeModule;
|
||||
public abstract fun getNativeModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule;
|
||||
public abstract fun getNativeModules ()Ljava/util/Collection;
|
||||
public fun getNativeModulesMessageQueueThread ()Lcom/facebook/react/bridge/queue/MessageQueueThread;
|
||||
public abstract fun getSourceURL ()Ljava/lang/String;
|
||||
|
@ -4968,6 +4970,7 @@ public class com/facebook/react/uimanager/ThemedReactContext : com/facebook/reac
|
|||
public fun getJavaScriptContextHolder ()Lcom/facebook/react/bridge/JavaScriptContextHolder;
|
||||
public fun getModuleName ()Ljava/lang/String;
|
||||
public fun getNativeModule (Ljava/lang/Class;)Lcom/facebook/react/bridge/NativeModule;
|
||||
public fun getNativeModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule;
|
||||
public fun getNativeModules ()Ljava/util/Collection;
|
||||
public fun getReactApplicationContext ()Lcom/facebook/react/bridge/ReactApplicationContext;
|
||||
public fun getSourceURL ()Ljava/lang/String;
|
||||
|
|
|
@ -129,6 +129,14 @@ public class BridgeReactContext extends ReactApplicationContext {
|
|||
return mCatalystInstance.getNativeModule(nativeModuleInterface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable NativeModule getNativeModule(String moduleName) {
|
||||
if (mCatalystInstance == null) {
|
||||
raiseCatalystInstanceMissingException();
|
||||
}
|
||||
return mCatalystInstance.getNativeModule(moduleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatalystInstance getCatalystInstance() {
|
||||
return Assertions.assertNotNull(mCatalystInstance);
|
||||
|
|
|
@ -150,6 +150,11 @@ public abstract class ReactContext extends ContextWrapper {
|
|||
@Nullable
|
||||
public abstract <T extends NativeModule> T getNativeModule(Class<T> nativeModuleInterface);
|
||||
|
||||
/**
|
||||
* @return the instance of the specified module interface associated with this ReactContext.
|
||||
*/
|
||||
public abstract @Nullable NativeModule getNativeModule(String moduleName);
|
||||
|
||||
/**
|
||||
* Calls RCTDeviceEventEmitter.emit to JavaScript, with given event name and an optional list of
|
||||
* arguments.
|
||||
|
|
|
@ -181,6 +181,11 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
|||
return mReactHost.getNativeModule(nativeModuleInterface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable NativeModule getNativeModule(String name) {
|
||||
return mReactHost.getNativeModule(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@FrameworkAPI
|
||||
@UnstableReactNativeAPI
|
||||
|
|
|
@ -100,6 +100,12 @@ public class ThemedReactContext extends ReactContext {
|
|||
return mReactApplicationContext.getNativeModule(nativeModuleInterface);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NativeModule getNativeModule(String moduleName) {
|
||||
return mReactApplicationContext.getNativeModule(moduleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatalystInstance getCatalystInstance() {
|
||||
return mReactApplicationContext.getCatalystInstance();
|
||||
|
|
Загрузка…
Ссылка в новой задаче