ReactHost

interface ReactHost

A ReactHost is an object that manages a single ReactInstance. A ReactHost can be constructed without initializing the ReactInstance, and it will continue to exist after the instance is destroyed.

The implementation of this interface should be Thread Safe

Inheritors

Properties

Link copied to clipboard

The current ReactContext associated with ReactInstance. It could be nullable if ReactInstance hasn't been created.

Link copied to clipboard

DevSupportManager used by this ReactHost

Link copied to clipboard

The current LifecycleState for React Host

Link copied to clipboard

Routes memory pressure events to interested components

Link copied to clipboard

ReactQueueConfiguration for caller to post jobs in React Native threads

Functions

Link copied to clipboard
abstract fun addBeforeDestroyListener(onBeforeDestroy: () -> Unit)
Link copied to clipboard

Add a listener to be notified of ReactInstance events.

Link copied to clipboard
abstract fun createSurface(context: Context, moduleName: String, initialProps: Bundle?): ReactSurface

To be called to create and setup an ReactSurface.

Link copied to clipboard
abstract fun destroy(reason: String, ex: Exception?): TaskInterface<Void>
abstract fun destroy(reason: String, ex: Exception?, onDestroyFinished: (instanceDestroyedSuccessfully: Boolean) -> Unit = {}): TaskInterface<Void>

Entrypoint to destroy the ReactInstance. If the ReactInstance is reloading, will wait until reload is finished, before destroying.

Link copied to clipboard
abstract fun invalidate()

Permanently destroys the ReactHost, including the ReactInstance (if any). The application MUST NOT call any further methods on an invalidated ReactHost.

Link copied to clipboard
abstract fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?)
Link copied to clipboard
abstract fun onBackPressed(): Boolean

To be called when back button is pressed

Link copied to clipboard
abstract fun onConfigurationChanged(context: Context)
Link copied to clipboard
abstract fun onHostDestroy()
abstract fun onHostDestroy(activity: Activity?)

To be called when the host activity is destroyed.

Link copied to clipboard
abstract fun onHostLeaveHint(activity: Activity?)

To be called when the host activity is about to go into the background as the result of user choice.

Link copied to clipboard
abstract fun onHostPause()
abstract fun onHostPause(activity: Activity?)

To be called when the host activity is paused.

Link copied to clipboard
abstract fun onHostResume(activity: Activity?)
abstract fun onHostResume(activity: Activity?, defaultBackButtonImpl: DefaultHardwareBackBtnHandler?)

To be called when the host activity is resumed.

Link copied to clipboard
abstract fun onNewIntent(intent: Intent)
Link copied to clipboard
abstract fun onWindowFocusChange(hasFocus: Boolean)
Link copied to clipboard
abstract fun reload(reason: String): TaskInterface<Void>

Entrypoint to reload the ReactInstance. If the ReactInstance is destroying, will wait until destroy is finished, before reloading.

Link copied to clipboard
abstract fun removeBeforeDestroyListener(onBeforeDestroy: () -> Unit)
Link copied to clipboard

Remove a listener previously added with addReactInstanceEventListener.

Link copied to clipboard
abstract fun start(): TaskInterface<Void>

This function can be used to initialize the ReactInstance in a background thread before a surface needs to be rendered. It is not necessary to call this function; startSurface() will initialize the ReactInstance if it hasn't been preloaded.