From 20808b5eb58a557fc730821d46c6459fa4b7fe79 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 25 May 2023 10:29:01 -0700 Subject: [PATCH] Document ReactHostDelegate (#37562) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37562 Add documentation for ReactHostDelegate changelog: [internal] internal Reviewed By: cortinico Differential Revision: D45717674 fbshipit-source-id: e0d6d70edf4f4cf70b53807732b35f5fda917fc3 --- .../react/bridgeless/ReactHostDelegate.kt | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHostDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHostDelegate.kt index fc56651a7d8..e198af4fc83 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHostDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHostDelegate.kt @@ -16,24 +16,51 @@ import com.facebook.react.common.annotations.UnstableReactNativeAPI import com.facebook.react.fabric.ReactNativeConfig import com.facebook.react.turbomodule.core.TurboModuleManagerDelegate -/** TODO: add javadoc for class and methods */ +/** + * [ReactHostDelegate] is an interface that defines parameters required to initialize React Native. + * This interface works in combination with [ReactHost] + */ @ThreadSafe @UnstableReactNativeAPI interface ReactHostDelegate { + /** + * Path to your app's main module on Metro. This is used when reloading JS during development. All + * paths are relative to the root folder the packager is serving files from. Examples: + * `index.android` or `subdirectory/index.android` + */ val jSMainModulePath: String + /** + * Object that holds a native C++ references that allow host applications to install C++ objects + * into jsi::Runtime during the initialization of React Native + */ val bindingsInstaller: BindingsInstaller? + /** list of [ReactPackage] to expose Native Modules and View Components to JS */ val reactPackages: List + /** Object that holds a native reference to the javascript engine */ val jSEngineInstance: JSEngineInstance + /** + * Bundle loader to use when setting up JS environment.

Example: + * [JSBundleLoader.createFileLoader(application, bundleFile)] + */ val jSBundleLoader: JSBundleLoader + /** TODO: combine getTurboModuleManagerDelegate inside [ReactPackage] */ fun getTurboModuleManagerDelegate(context: ReactApplicationContext): TurboModuleManagerDelegate + /** + * Callback that can be used by React Native host applications to react to exceptions thrown by + * the internals of React Native. + */ fun handleInstanceException(error: Exception) + /** + * ReactNative Configuration that allows to customize the behavior of key/value pairs used by the + * framework to enable/disable experimental capabilities + */ fun getReactNativeConfig(context: ReactContext): ReactNativeConfig @UnstableReactNativeAPI