15
15
16
16
17
17
RCTBridge * bridgeRef;
18
+ dispatch_queue_t commonTaskQueue;
19
+ dispatch_queue_t fsQueue;
18
20
19
21
// //////////////////////////////////////
20
22
//
@@ -30,7 +32,9 @@ @implementation RNFetchBlob
30
32
@synthesize bridge = _bridge;
31
33
32
34
- (dispatch_queue_t ) methodQueue {
33
- return dispatch_queue_create (" RNFetchBlob.queue" , DISPATCH_QUEUE_SERIAL);
35
+ if (commonTaskQueue == nil )
36
+ commonTaskQueue = dispatch_queue_create (" RNFetchBlob.queue" , DISPATCH_QUEUE_SERIAL);
37
+ return commonTaskQueue;
34
38
}
35
39
36
40
+ (RCTBridge *)getRCTBridge
@@ -43,6 +47,10 @@ + (RCTBridge *)getRCTBridge
43
47
- (id ) init {
44
48
self = [super init ];
45
49
self.filePathPrefix = FILE_PREFIX;
50
+ if (commonTaskQueue == nil )
51
+ commonTaskQueue = dispatch_queue_create (" RNFetchBlob.queue" , DISPATCH_QUEUE_SERIAL);
52
+ if (fsQueue == nil )
53
+ fsQueue = dispatch_queue_create (" RNFetchBlob.fs.queue" , DISPATCH_QUEUE_SERIAL);
46
54
BOOL isDir;
47
55
// if temp folder not exists, create one
48
56
if (![[NSFileManager defaultManager ] fileExistsAtPath: [RNFetchBlobFS getTempPath ] isDirectory: &isDir]) {
@@ -376,17 +384,16 @@ - (NSDictionary *)constantsToExport
376
384
#pragma mark - fs.readStream
377
385
RCT_EXPORT_METHOD (readStream:(NSString *)path withEncoding:(NSString *)encoding bufferSize:(int )bufferSize tick:(int )tick streamId:(NSString *)streamId
378
386
{
379
-
380
- // RNFetchBlobFS *fileStream = [[RNFetchBlobFS alloc] initWithBridgeRef:self.bridge];
381
387
if (bufferSize == nil ) {
382
388
if ([[encoding lowercaseString ] isEqualToString: @" base64" ])
383
389
bufferSize = 4095 ;
384
390
else
385
391
bufferSize = 4096 ;
386
392
}
387
393
388
- // [fileStream readWithPath:path useEncoding:encoding bufferSize:bufferSize];
389
- [RNFetchBlobFS readStream: path encoding: encoding bufferSize: bufferSize tick: tick streamId: streamId bridgeRef: _bridge];
394
+ dispatch_async (fsQueue, ^{
395
+ [RNFetchBlobFS readStream: path encoding: encoding bufferSize: bufferSize tick: tick streamId: streamId bridgeRef: _bridge];
396
+ });
390
397
})
391
398
392
399
#pragma mark - fs.getEnvionmentDirs
0 commit comments