public final class NetworkingModule extends ReactContextBaseJavaModule
Modifier and Type | Class and Description |
---|---|
static interface |
NetworkingModule.RequestBodyHandler
Allows adding custom handling to build the
RequestBody from the JS body payload. |
static interface |
NetworkingModule.ResponseHandler
Allows adding custom handling to build the JS body payload from the
ResponseBody . |
static interface |
NetworkingModule.UriHandler
Allows to implement a custom fetching process for specific URIs.
|
NativeModule.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(int requestId) |
void |
addRequestBodyHandler(NetworkingModule.RequestBodyHandler handler) |
void |
addResponseHandler(NetworkingModule.ResponseHandler handler) |
void |
addUriHandler(NetworkingModule.UriHandler handler) |
void |
clearCookies(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 |
removeRequestBodyHandler(NetworkingModule.RequestBodyHandler handler) |
void |
removeResponseHandler(NetworkingModule.ResponseHandler handler) |
void |
removeUriHandler(NetworkingModule.UriHandler handler) |
void |
sendRequest(java.lang.String method,
java.lang.String url,
int requestId,
ReadableArray headers,
ReadableMap data,
java.lang.String responseType,
boolean useIncrementalUpdates,
int timeout,
boolean withCredentials) |
getCurrentActivity, getReactApplicationContext
canOverrideExistingModule, getConstants, hasConstants
protected 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()
NativeModule
CatalystApplicationFragment#createCatalystInstance()
after the CatalystInstance has been created, in order to initialize NativeModules that require
the CatalystInstance or JS modules.initialize
in interface NativeModule
initialize
in class BaseJavaModule
public java.lang.String getName()
require()
this module
from javascript.public void onCatalystInstanceDestroy()
NativeModule
onCatalystInstanceDestroy
in interface NativeModule
onCatalystInstanceDestroy
in class BaseJavaModule
public void addUriHandler(NetworkingModule.UriHandler handler)
public void addRequestBodyHandler(NetworkingModule.RequestBodyHandler handler)
public void addResponseHandler(NetworkingModule.ResponseHandler handler)
public void removeUriHandler(NetworkingModule.UriHandler handler)
public void removeRequestBodyHandler(NetworkingModule.RequestBodyHandler handler)
public void removeResponseHandler(NetworkingModule.ResponseHandler handler)
public void sendRequest(java.lang.String method, java.lang.String url, int requestId, ReadableArray headers, ReadableMap data, java.lang.String responseType, boolean useIncrementalUpdates, int timeout, boolean withCredentials)
public void abortRequest(int requestId)
public void clearCookies(Callback callback)