-
- All Implemented Interfaces:
-
com.facebook.react.bridge.JSBundleLoaderDelegate
,com.facebook.react.bridge.JSInstance
,com.facebook.react.bridge.MemoryPressureListener
public interface CatalystInstance implements MemoryPressureListener, JSInstance, JSBundleLoaderDelegate
A higher level API on top of the asynchronous JSC bridge. This provides an environment allowing the invocation of JavaScript methods and lets a set of Java APIs be invokable from JavaScript as well.
-
-
Method Summary
Modifier and Type Method Description abstract void
runJSBundle()
abstract boolean
hasRunJSBundle()
abstract String
getSourceURL()
Return the source URL of the JS Bundle that was run, or {@code null}
if no JS bundle has beenrun yet.abstract void
invokeCallback(int callbackID, NativeArrayInterface arguments)
abstract void
callFunction(String module, String method, NativeArray arguments)
abstract void
destroy()
Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration(besides the UI thread) to finish running. abstract boolean
isDestroyed()
abstract void
initialize()
Initialize all the native modules abstract ReactQueueConfiguration
getReactQueueConfiguration()
abstract <T extends JavaScriptModule> T
getJSModule(Class<T> jsInterface)
abstract <T extends NativeModule> boolean
hasNativeModule(Class<T> nativeModuleInterface)
abstract <T extends NativeModule> T
getNativeModule(Class<T> nativeModuleInterface)
abstract NativeModule
getNativeModule(String moduleName)
abstract JSIModule
getJSIModule(JSIModuleType moduleType)
abstract Collection<NativeModule>
getNativeModules()
abstract void
extendNativeModules(NativeModuleRegistry modules)
This method permits a CatalystInstance to extend the known Native modules. abstract void
addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
Adds a idle listener for this Catalyst instance. abstract void
removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
Removes a NotThreadSafeBridgeIdleDebugListener previously added with abstract void
registerSegment(int segmentId, String path)
This method registers the file path of an additional JS segment by its ID. abstract void
setGlobalVariable(String propName, String jsonValue)
abstract JavaScriptContextHolder
getJavaScriptContextHolder()
Do not use this anymore. abstract RuntimeExecutor
getRuntimeExecutor()
abstract RuntimeScheduler
getRuntimeScheduler()
abstract void
addJSIModules(List<JSIModuleSpec> jsiModules)
abstract CallInvokerHolder
getJSCallInvokerHolder()
Returns a hybrid object that contains a pointer to a JS CallInvoker, which is used to schedulework on the JS Thread. abstract CallInvokerHolder
getNativeCallInvokerHolder()
Returns a hybrid object that contains a pointer to a Native CallInvoker, which is used toschedule work on the NativeModules thread. abstract void
setTurboModuleManager(JSIModule getter)
For the time being, we want code relying on the old infra to also work with TurboModules.Hence, we must provide the TurboModuleRegistry to CatalystInstance so that getNativeModule,hasNativeModule, and getNativeModules can also return TurboModules. -
Methods inherited from class com.facebook.react.bridge.MemoryPressureListener
handleMemoryPressure
-
Methods inherited from class com.facebook.react.bridge.JSBundleLoaderDelegate
loadScriptFromAssets, loadScriptFromFile, loadSplitBundleFromFile, setSourceURLs
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
runJSBundle
abstract void runJSBundle()
-
hasRunJSBundle
abstract boolean hasRunJSBundle()
-
getSourceURL
@Nullable() abstract String getSourceURL()
Return the source URL of the JS Bundle that was run, or
{@code null}
if no JS bundle has beenrun yet.
-
invokeCallback
abstract void invokeCallback(int callbackID, NativeArrayInterface arguments)
-
callFunction
abstract void callFunction(String module, String method, NativeArray arguments)
-
destroy
abstract void destroy()
Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration(besides the UI thread) to finish running. Must be called from the UI thread so that we canfully shut down other threads.
-
isDestroyed
abstract boolean isDestroyed()
-
initialize
abstract void initialize()
Initialize all the native modules
-
getReactQueueConfiguration
abstract ReactQueueConfiguration getReactQueueConfiguration()
-
getJSModule
abstract <T extends JavaScriptModule> T getJSModule(Class<T> jsInterface)
-
hasNativeModule
abstract <T extends NativeModule> boolean hasNativeModule(Class<T> nativeModuleInterface)
-
getNativeModule
@Nullable() abstract <T extends NativeModule> T getNativeModule(Class<T> nativeModuleInterface)
-
getNativeModule
@Nullable() abstract NativeModule getNativeModule(String moduleName)
-
getJSIModule
abstract JSIModule getJSIModule(JSIModuleType moduleType)
-
getNativeModules
abstract Collection<NativeModule> getNativeModules()
-
extendNativeModules
abstract void extendNativeModules(NativeModuleRegistry modules)
This method permits a CatalystInstance to extend the known Native modules. This providedregistry contains only the new modules to load.
-
addBridgeIdleDebugListener
abstract void addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
Adds a idle listener for this Catalyst instance. The listener will receive notificationswhenever the bridge transitions from idle to busy and vice-versa, where the busy state isdefined as there being some non-zero number of calls to JS that haven't resolved via aonBatchCompleted call. The listener should be purely passive and not affect application logic.
-
removeBridgeIdleDebugListener
abstract void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
-
registerSegment
abstract void registerSegment(int segmentId, String path)
This method registers the file path of an additional JS segment by its ID.
-
setGlobalVariable
abstract void setGlobalVariable(String propName, String jsonValue)
-
getJavaScriptContextHolder
@Deprecated() abstract JavaScriptContextHolder getJavaScriptContextHolder()
Do not use this anymore. Use getRuntimeExecutor instead. Get the C pointer (as along) to the JavaScriptCore context associated with this instance.
Use the following pattern to ensure that the JS context is not cleared while you are usingit: JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder()synchronized(jsContext) { nativeThingNeedingJsContext(jsContext.get()); }
-
getRuntimeExecutor
abstract RuntimeExecutor getRuntimeExecutor()
-
getRuntimeScheduler
abstract RuntimeScheduler getRuntimeScheduler()
-
addJSIModules
abstract void addJSIModules(List<JSIModuleSpec> jsiModules)
-
getJSCallInvokerHolder
abstract CallInvokerHolder getJSCallInvokerHolder()
Returns a hybrid object that contains a pointer to a JS CallInvoker, which is used to schedulework on the JS Thread. Required for TurboModuleManager initialization.
-
getNativeCallInvokerHolder
abstract CallInvokerHolder getNativeCallInvokerHolder()
Returns a hybrid object that contains a pointer to a Native CallInvoker, which is used toschedule work on the NativeModules thread. Required for TurboModuleManager initialization.
-
setTurboModuleManager
abstract void setTurboModuleManager(JSIModule getter)
For the time being, we want code relying on the old infra to also work with TurboModules.Hence, we must provide the TurboModuleRegistry to CatalystInstance so that getNativeModule,hasNativeModule, and getNativeModules can also return TurboModules.
-
-
-
-