mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Refactored networking logic out into RCTDownloadTask
This commit is contained in:
40
Libraries/Network/RCTDownloadTask.h
Normal file
40
Libraries/Network/RCTDownloadTask.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "RCTURLRequestDelegate.h"
|
||||
#import "RCTURLRequestHandler.h"
|
||||
|
||||
typedef void (^RCTURLRequestCompletionBlock)(NSURLResponse *response, NSData *data, NSError *error);
|
||||
typedef void (^RCTURLRequestCancellationBlock)(void);
|
||||
typedef void (^RCTURLRequestIncrementalDataBlock)(NSData *data);
|
||||
typedef void (^RCTURLRequestProgressBlock)(double progress, double total);
|
||||
typedef void (^RCTURLRequestResponseBlock)(NSURLResponse *response);
|
||||
|
||||
@interface RCTDownloadTask : NSObject <RCTURLRequestDelegate>
|
||||
|
||||
@property (nonatomic, readonly) NSURLRequest *request;
|
||||
@property (nonatomic, readonly) NSNumber *requestID;
|
||||
@property (nonatomic, readonly) id requestToken;
|
||||
@property (nonatomic, readonly) NSURLResponse *response;
|
||||
@property (nonatomic, readonly) RCTURLRequestCompletionBlock completionBlock;
|
||||
|
||||
@property (nonatomic, copy) RCTURLRequestProgressBlock downloadProgressBlock;
|
||||
@property (nonatomic, copy) RCTURLRequestIncrementalDataBlock incrementalDataBlock;
|
||||
@property (nonatomic, copy) RCTURLRequestResponseBlock responseBlock;
|
||||
@property (nonatomic, copy) RCTURLRequestProgressBlock uploadProgressBlock;
|
||||
|
||||
- (instancetype)initWithRequest:(NSURLRequest *)request
|
||||
handler:(id<RCTURLRequestHandler>)handler
|
||||
completionBlock:(RCTURLRequestCompletionBlock)completionBlock NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user