public final class NetworkingModule extends NativeNetworkingAndroidSpec
Modifier and Type | Class and Description |
---|---|
static interface |
NetworkingModule.CustomClientBuilder |
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 |
---|---|
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(double requestIdAsDouble) |
void |
addListener(java.lang.String eventName) |
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 |
removeListeners(double count) |
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,
double requestIdAsDouble,
ReadableArray headers,
ReadableMap data,
java.lang.String responseType,
boolean useIncrementalUpdates,
double timeoutAsDouble,
boolean withCredentials) |
void |
sendRequestInternal(java.lang.String method,
java.lang.String url,
int requestId,
ReadableArray headers,
ReadableMap data,
java.lang.String responseType,
boolean useIncrementalUpdates,
int timeout,
boolean withCredentials) |
static void |
setCustomClientBuilder(NetworkingModule.CustomClientBuilder ccb) |
getCurrentActivity, getReactApplicationContext, getReactApplicationContextIfActiveOrWarn
canOverrideExistingModule, getConstants, hasConstants, invalidate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invalidate
public 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 static void setCustomClientBuilder(NetworkingModule.CustomClientBuilder ccb)
public 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, double requestIdAsDouble, ReadableArray headers, ReadableMap data, java.lang.String responseType, boolean useIncrementalUpdates, double timeoutAsDouble, boolean withCredentials)
sendRequest
in class NativeNetworkingAndroidSpec
public void sendRequestInternal(java.lang.String method, java.lang.String url, int requestId, ReadableArray headers, ReadableMap data, java.lang.String responseType, boolean useIncrementalUpdates, int timeout, boolean withCredentials)
timeout
- value of 0 results in no timeoutpublic void abortRequest(double requestIdAsDouble)
abortRequest
in class NativeNetworkingAndroidSpec
public void clearCookies(Callback callback)
clearCookies
in class NativeNetworkingAndroidSpec
public void addListener(java.lang.String eventName)
addListener
in class NativeNetworkingAndroidSpec
public void removeListeners(double count)
removeListeners
in class NativeNetworkingAndroidSpec