Introduce ReactInstanceDelegate.Builder (#37280)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37280

In this diff I'm introducing the ReactInstanceDelegate.Builder class that will be used to initialize ReactHost in Android

This class is still under development, it is missing:
- Tests
- Documentantion for class and methods
- Default objects for optional fields on ReactInstanceDelegate.Builder

The goal of this diff is to introduce the class, test UnstableReactNativeAPI annotation and create a diff stack that shows the process to create a stable API in Android.

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D45509432

fbshipit-source-id: 7ae12f6b146491953a78edf02acf0e1ee8f8fce5
This commit is contained in:
David Vacca
2023-05-05 11:55:24 -07:00
committed by Facebook GitHub Bot
parent 8cfc1c3e75
commit 1b848c5ad0
@@ -16,6 +16,7 @@ import com.facebook.react.fabric.ReactNativeConfig
import com.facebook.react.turbomodule.core.TurboModuleManager
import com.facebook.react.turbomodule.core.TurboModuleManagerDelegate
/** TODO: add javadoc for class and methods */
@ThreadSafe
interface ReactInstanceDelegate {
val jSMainModulePath: String
@@ -33,4 +34,26 @@ interface ReactInstanceDelegate {
fun handleInstanceException(e: Exception)
fun getReactNativeConfig(turboModuleManager: TurboModuleManager): ReactNativeConfig
class ReactInstanceDelegateBase(
override val jSMainModulePath: String,
override val bindingsInstaller: BindingsInstaller,
override val reactPackages: List<ReactPackage>,
private val jsBundleLoader: JSBundleLoader,
private val turboModuleManagerDelegate: TurboModuleManagerDelegate,
private val jsEngineInstance: JSEngineInstance,
private val reactNativeConfig: ReactNativeConfig,
private val exceptionHandler: (Exception) -> Unit = {}
) : ReactInstanceDelegate {
override fun getJSBundleLoader(context: Context) = jsBundleLoader
override fun getTurboModuleManagerDelegate(context: ReactApplicationContext) =
turboModuleManagerDelegate
override fun getJSEngineInstance(context: ReactApplicationContext) = jsEngineInstance
override fun getReactNativeConfig(turboModuleManager: TurboModuleManager) = reactNativeConfig
override fun handleInstanceException(e: Exception) = exceptionHandler(e)
}
}