Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getNativeModule(String) to ReactContext interface #44851

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public <T extends NativeModule> T getNativeModule(Class<T> nativeModuleInterface
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public Object getSystemService(String name) {
@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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ public Collection<NativeModule> getNativeModules() {
return mReactHost.getNativeModule(nativeModuleInterface);
}

@Override
public @Nullable NativeModule getNativeModule(String name) {
return mReactHost.getNativeModule(name);
}

@Override
@FrameworkAPI
@UnstableReactNativeAPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public <T extends NativeModule> T getNativeModule(Class<T> nativeModuleInterface
return mReactApplicationContext.getNativeModule(nativeModuleInterface);
}

@Nullable
@Override
public NativeModule getNativeModule(String moduleName) {
return mReactApplicationContext.getNativeModule(moduleName);
}

@Override
public CatalystInstance getCatalystInstance() {
return mReactApplicationContext.getCatalystInstance();
Expand Down
Loading