mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
[ReactNative] Refactor RCTDataManager to support pluggable data source modules (RCTURLRequestHandlers)
Summary: @public This is a refactor of @philikon's original diff that decouples the dependencies between the Network and Image modules, and replaces RCTDataQueryExecutor with a more useful abstraction. I've introduced the RCTURLRequestHandler protocol, which is a new type of bridge module used for loading data using an NSURLRequest. RCTURLRequestHandlers can be registered using RCT_EXPORT_MODULE() and are then available at runtime for use by the RCTDataManager, which will automatically select the appropriate handler for a given request based on the handler's self-reported capabilities. The currently implemented handlers are: - RCTHTTPRequestHandler - the standard open source HTTP request handler that uses NSURLSession - RKHTTPRequestHandler - the internal FB HTTP request handler that uses FBNetworking - RCTImageRequestHandler - a handler for loading local images from the iOS asset-library Depends on D2108193 Test Plan: - Internal apps still work - OSS port still compiles, Movies app and a sample Parse app still work - uploading image to Parse using the above code snippet works - tested `FormData` with string and image parameters using http://www.posttestserver.com/
This commit is contained in:
@@ -61,10 +61,6 @@ RCT_EXTERN BOOL RCTImageHasAlpha(CGImageRef image);
|
||||
// Create an NSError in the NCTErrorDomain
|
||||
RCT_EXTERN NSError *RCTErrorWithMessage(NSString *message);
|
||||
|
||||
// Dispatch an error + result callback on the main thread.
|
||||
typedef void (^RCTResultOrErrorBlock)(NSError *error, id result);
|
||||
RCT_EXTERN void RCTDispatchCallbackOnMainQueue(RCTResultOrErrorBlock callback, NSError *error, id result);
|
||||
|
||||
// Convert nil values to NSNull, and vice-versa
|
||||
RCT_EXTERN id RCTNullIfNil(id value);
|
||||
RCT_EXTERN id RCTNilIfNull(id value);
|
||||
|
||||
Reference in New Issue
Block a user