public class CatalystInstanceImpl extends java.lang.Object implements CatalystInstance
Modifier and Type | Class and Description |
---|---|
static class |
CatalystInstanceImpl.Builder |
static class |
CatalystInstanceImpl.PendingJSCall |
Modifier and Type | Method and Description |
---|---|
void |
addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
Adds a idle listener for this Catalyst instance.
|
void |
addJSIModules(java.util.List<JSIModuleSpec> jsiModules) |
void |
callFunction(CatalystInstanceImpl.PendingJSCall function) |
void |
callFunction(java.lang.String module,
java.lang.String method,
NativeArray arguments) |
void |
destroy()
Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
(besides the UI thread) to finish running.
|
void |
extendNativeModules(NativeModuleRegistry modules)
This method and the native below permits a CatalystInstance to extend the known
Native modules.
|
JavaScriptContextHolder |
getJavaScriptContextHolder()
Get the C pointer (as a long) to the JavaScriptCore context associated with this instance.
|
<T extends JSIModule> |
getJSIModule(java.lang.Class<T> jsiModuleInterface) |
<T extends JavaScriptModule> |
getJSModule(java.lang.Class<T> jsInterface) |
<T extends NativeModule> |
getNativeModule(java.lang.Class<T> nativeModuleInterface) |
NativeModule |
getNativeModule(java.lang.String moduleName) |
java.util.Collection<NativeModule> |
getNativeModules() |
ReactQueueConfiguration |
getReactQueueConfiguration() |
java.lang.String |
getSourceURL()
Return the source URL of the JS Bundle that was run, or
null if no JS
bundle has been run yet. |
void |
handleMemoryPressure(int level)
Called when the system generates a memory warning.
|
<T extends NativeModule> |
hasNativeModule(java.lang.Class<T> nativeModuleInterface) |
boolean |
hasRunJSBundle() |
void |
initialize()
Initialize all the native modules
|
void |
invokeCallback(int callbackID,
NativeArrayInterface arguments) |
boolean |
isDestroyed() |
void |
loadScriptFromAssets(android.content.res.AssetManager assetManager,
java.lang.String assetURL,
boolean loadSynchronously)
Load a JS bundle from Android assets.
|
void |
loadScriptFromDeltaBundle(java.lang.String sourceURL,
NativeDeltaClient deltaClient,
boolean loadSynchronously)
Load a delta bundle from Metro.
|
void |
loadScriptFromFile(java.lang.String fileName,
java.lang.String sourceURL,
boolean loadSynchronously)
Load a JS bundle from the filesystem.
|
void |
registerSegment(int segmentId,
java.lang.String path)
This method registers the file path of an additional JS segment by its ID.
|
void |
removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
Removes a NotThreadSafeBridgeIdleDebugListener previously added with
addBridgeIdleDebugListener(com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener) |
void |
runJSBundle() |
void |
setGlobalVariable(java.lang.String propName,
java.lang.String jsonValue) |
void |
setSourceURLs(java.lang.String deviceURL,
java.lang.String remoteURL)
This API is used in situations where the JS bundle is being executed not on
the device, but on a host machine.
|
public void extendNativeModules(NativeModuleRegistry modules)
mNativeModuleRegistry
updates internally to contain all the new modules, and generates
the new registry for extracting just the new collections.extendNativeModules
in interface CatalystInstance
public void setSourceURLs(java.lang.String deviceURL, java.lang.String remoteURL)
JSBundleLoaderDelegate
setSourceURLs
in interface JSBundleLoaderDelegate
deviceURL
- A source URL that is accessible from this device.remoteURL
- A source URL that is accessible from the remote machine
executing the JS.public void registerSegment(int segmentId, java.lang.String path)
CatalystInstance
registerSegment
in interface CatalystInstance
public void loadScriptFromAssets(android.content.res.AssetManager assetManager, java.lang.String assetURL, boolean loadSynchronously)
JSBundleLoaderDelegate
JSBundleLoader.createAssetLoader(Context, String, boolean)
loadScriptFromAssets
in interface JSBundleLoaderDelegate
public void loadScriptFromFile(java.lang.String fileName, java.lang.String sourceURL, boolean loadSynchronously)
JSBundleLoaderDelegate
JSBundleLoader.createFileLoader(String)
and JSBundleLoader.createCachedBundleFromNetworkLoader(String, String)
loadScriptFromFile
in interface JSBundleLoaderDelegate
public void loadScriptFromDeltaBundle(java.lang.String sourceURL, NativeDeltaClient deltaClient, boolean loadSynchronously)
JSBundleLoaderDelegate
JSBundleLoader.createDeltaFromNetworkLoader(String, NativeDeltaClient)
loadScriptFromDeltaBundle
in interface JSBundleLoaderDelegate
public void runJSBundle()
runJSBundle
in interface CatalystInstance
public boolean hasRunJSBundle()
hasRunJSBundle
in interface CatalystInstance
public java.lang.String getSourceURL()
CatalystInstance
null
if no JS
bundle has been run yet.getSourceURL
in interface CatalystInstance
public void callFunction(java.lang.String module, java.lang.String method, NativeArray arguments)
callFunction
in interface CatalystInstance
public void callFunction(CatalystInstanceImpl.PendingJSCall function)
public void invokeCallback(int callbackID, NativeArrayInterface arguments)
invokeCallback
in interface CatalystInstance
invokeCallback
in interface JSInstance
public void destroy()
destroy
in interface CatalystInstance
public boolean isDestroyed()
isDestroyed
in interface CatalystInstance
public void initialize()
initialize
in interface CatalystInstance
public ReactQueueConfiguration getReactQueueConfiguration()
getReactQueueConfiguration
in interface CatalystInstance
public <T extends JavaScriptModule> T getJSModule(java.lang.Class<T> jsInterface)
getJSModule
in interface CatalystInstance
public <T extends NativeModule> boolean hasNativeModule(java.lang.Class<T> nativeModuleInterface)
hasNativeModule
in interface CatalystInstance
public <T extends NativeModule> T getNativeModule(java.lang.Class<T> nativeModuleInterface)
getNativeModule
in interface CatalystInstance
public NativeModule getNativeModule(java.lang.String moduleName)
getNativeModule
in interface CatalystInstance
public java.util.Collection<NativeModule> getNativeModules()
getNativeModules
in interface CatalystInstance
public void handleMemoryPressure(int level)
MemoryPressureListener
handleMemoryPressure
in interface MemoryPressureListener
public void addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
addBridgeIdleDebugListener
in interface CatalystInstance
public void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener)
addBridgeIdleDebugListener(com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener)
removeBridgeIdleDebugListener
in interface CatalystInstance
public void setGlobalVariable(java.lang.String propName, java.lang.String jsonValue)
setGlobalVariable
in interface CatalystInstance
public JavaScriptContextHolder getJavaScriptContextHolder()
CatalystInstance
Use the following pattern to ensure that the JS context is not cleared while you are using it: JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder() synchronized(jsContext) { nativeThingNeedingJsContext(jsContext.get()); }
getJavaScriptContextHolder
in interface CatalystInstance
public void addJSIModules(java.util.List<JSIModuleSpec> jsiModules)
addJSIModules
in interface CatalystInstance
public <T extends JSIModule> T getJSIModule(java.lang.Class<T> jsiModuleInterface)
getJSIModule
in interface CatalystInstance