Skip to content

Commit

Permalink
Support more stubbed methods in BridgelessCatalystInstance (#44091)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44091

These can be stubbed easily using existing ReactHostImpl/ReactInstance API's

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D56139806

fbshipit-source-id: cefabe3aa0fb6556f8e296243ff233df07ddffee
  • Loading branch information
javache authored and cipolleschi committed May 2, 2024
1 parent 58b1f9b commit cc1c697
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,20 @@ public class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) :
throw UnsupportedOperationException("Unimplemented method 'initialize'")
}

override fun getReactQueueConfiguration(): ReactQueueConfiguration {
throw UnsupportedOperationException("Unimplemented method 'getReactQueueConfiguration'")
}
override fun getReactQueueConfiguration(): ReactQueueConfiguration =
reactHost.reactQueueConfiguration!!

override fun <T : JavaScriptModule> getJSModule(jsInterface: Class<T>): T {
throw UnsupportedOperationException("Unimplemented method 'getJSModule'")
}
override fun <T : JavaScriptModule> getJSModule(jsInterface: Class<T>): T =
reactHost.currentReactContext?.getJSModule(jsInterface)!!

override fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean {
throw UnsupportedOperationException("Unimplemented method 'hasNativeModule'")
}
override fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean =
reactHost.hasNativeModule(nativeModuleInterface)

override fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? {
throw UnsupportedOperationException("Unimplemented method 'getNativeModule'")
}
override fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? =
reactHost.getNativeModule(nativeModuleInterface)

override fun getNativeModule(moduleName: String): NativeModule? {
throw UnsupportedOperationException("Unimplemented method 'getNativeModule'")
}
override fun getNativeModule(moduleName: String): NativeModule? =
reactHost.getNativeModule(moduleName)

@Deprecated(
message =
Expand All @@ -119,9 +114,7 @@ public class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) :
throw UnsupportedOperationException("Unimplemented method 'getJSIModule'")
}

override fun getNativeModules(): Collection<NativeModule> {
throw UnsupportedOperationException("Unimplemented method 'getNativeModules'")
}
override fun getNativeModules(): Collection<NativeModule> = reactHost.getNativeModules()

override fun extendNativeModules(modules: NativeModuleRegistry) {
throw UnsupportedOperationException("Unimplemented method 'extendNativeModules'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,16 @@ <T extends NativeModule> T getNativeModule(Class<T> nativeModuleInterface) {
return null;
}

/* package */
@Nullable
NativeModule getNativeModule(String nativeModuleName) {
final ReactInstance reactInstance = mReactInstanceTaskRef.get().getResult();
if (reactInstance != null) {
return reactInstance.getNativeModule(nativeModuleName);
}
return null;
}

/* package */
@Nullable
RuntimeExecutor getRuntimeExecutor() {
Expand Down

0 comments on commit cc1c697

Please sign in to comment.