public final class NetworkingModule extends ReactContextBaseJavaModule
BaseJavaModule.JavaMethodNativeModule.NativeMethod| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
NAME |
METHOD_TYPE_ASYNC, METHOD_TYPE_PROMISE, METHOD_TYPE_SYNC| Constructor and Description |
|---|
NetworkingModule(ReactApplicationContext context) |
NetworkingModule(ReactApplicationContext context,
java.util.List<NetworkInterceptorCreator> networkInterceptorCreators) |
NetworkingModule(ReactApplicationContext context,
java.lang.String defaultUserAgent) |
| Modifier and Type | Method and Description |
|---|---|
void |
abortRequest(ExecutorToken executorToken,
int requestId) |
void |
clearCookies(ExecutorToken executorToken,
Callback callback) |
java.lang.String |
getName() |
void |
initialize()
This is called at the end of
CatalystApplicationFragment#createCatalystInstance()
after the CatalystInstance has been created, in order to initialize NativeModules that require
the CatalystInstance or JS modules. |
void |
onCatalystInstanceDestroy()
Called before {CatalystInstance#onHostDestroy}
|
void |
sendRequest(ExecutorToken executorToken,
java.lang.String method,
java.lang.String url,
int requestId,
ReadableArray headers,
ReadableMap data,
java.lang.String responseType,
boolean useIncrementalUpdates,
int timeout) |
boolean |
supportsWebWorkers()
In order to support web workers, a module must be aware that it can be invoked from multiple
different JS VMs.
|
getCurrentActivity, getReactApplicationContextcanOverrideExistingModule, getConstants, getMethodsprotected static final java.lang.String NAME
public NetworkingModule(ReactApplicationContext context)
context - the ReactContext of the applicationpublic NetworkingModule(ReactApplicationContext context, java.util.List<NetworkInterceptorCreator> networkInterceptorCreators)
context - the ReactContext of the applicationnetworkInterceptorCreators - list of NetworkInterceptorCreator's whose create()
methods would be called to attach the interceptors to the client.public NetworkingModule(ReactApplicationContext context, java.lang.String defaultUserAgent)
context - the ReactContext of the applicationdefaultUserAgent - the User-Agent header that will be set for all requests where the
caller does not provide one explicitlypublic void initialize()
NativeModuleCatalystApplicationFragment#createCatalystInstance()
after the CatalystInstance has been created, in order to initialize NativeModules that require
the CatalystInstance or JS modules.initialize in interface NativeModuleinitialize in class BaseJavaModulepublic java.lang.String getName()
require() this module
from javascript.public void onCatalystInstanceDestroy()
NativeModuleonCatalystInstanceDestroy in interface NativeModuleonCatalystInstanceDestroy in class BaseJavaModulepublic void sendRequest(ExecutorToken executorToken, java.lang.String method, java.lang.String url, int requestId, ReadableArray headers, ReadableMap data, java.lang.String responseType, boolean useIncrementalUpdates, int timeout)
public void abortRequest(ExecutorToken executorToken, int requestId)
public void clearCookies(ExecutorToken executorToken, Callback callback)
public boolean supportsWebWorkers()
NativeModuleExecutorToken as the first parameter before any arguments
from JS. This ExecutorToken internally maps to a specific JS VM and can be used by the
framework to route calls appropriately. In order to make JS module calls correctly, start using
the version of ReactContext.getJSModule(ExecutorToken, Class) that takes an
ExecutorToken. It will ensure that any calls you dispatch to the returned object will go to
the right VM. For Callbacks, you don't have to do anything special -- the framework
automatically tags them with the correct ExecutorToken when the are created.
Note: even though calls can come from multiple JS VMs on multiple threads, calls to this module
will still only occur on a single thread.supportsWebWorkers in interface NativeModulesupportsWebWorkers in class BaseJavaModule