Skip to content

Commit 9d8b4eb

Browse files
author
Ron Radtke
committed
fetch part working for ios
1 parent fa124db commit 9d8b4eb

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

fetch.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {ReactNativeBlobUtilConfig} from 'types';
22
import URIUtil from './utils/uri';
33
import fs from './fs';
44
import getUUID from './utils/uuid';
5-
import {DeviceEventEmitter, NativeEventEmitter, NativeModules} from 'react-native';
5+
import {DeviceEventEmitter, NativeEventEmitter} from 'react-native';
66
import {FetchBlobResponse} from './class/ReactNativeBlobUtilBlobResponse';
77
import CanceledFetchError from './class/ReactNativeBlobUtilCanceledFetchError';
88
import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
@@ -12,6 +12,7 @@ const eventEmitter = new NativeEventEmitter(ReactNativeBlobUtil);
1212
// register message channel event handler.
1313
eventEmitter.addListener('ReactNativeBlobUtilMessage', (e) => {
1414

15+
console.log('add listener')
1516
if (e.event === 'warn') {
1617
console.warn(e.detail);
1718
}
@@ -201,6 +202,7 @@ export function fetch(...args: any): Promise {
201202
});
202203

203204
stateEvent = eventEmitter.addListener('ReactNativeBlobUtilState', (e) => {
205+
console.log('state', e, typeof e, taskId, e.taskId)
204206
if (e.taskId === taskId)
205207
respInfo = e;
206208
promise.onStateChange && promise.onStateChange(e);

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a MIT-style license that can be
33
// found in the LICENSE file.
44

5-
import {AppState, Platform,} from 'react-native';
65
import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
76

87
//import StatefulPromise from './class/StatefulPromise.js'

ios/ReactNativeBlobUtil/ReactNativeBlobUtil.mm

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ @implementation ReactNativeBlobUtil
3333
@synthesize bridge;
3434
bool hasListeners;
3535

36+
- (NSArray<NSString*> *)supportedEvents {
37+
return @[@"ReactNativeBlobUtilState", @"ReactNativeBlobUtilServerPush", @"ReactNativeBlobUtilProgress", @"ReactNativeBlobUtilProgress-upload", @"ReactNativeBlobUtilExpire", @"ReactNativeBlobUtilMessage", @"log", @"warn", @"error", @"data", @"end", @"reportProgress", @"reportUploadProgress"];
38+
}
39+
3640
// Will be called when this module's first listener is added.
3741
-(void)startObserving {
3842
hasListeners = YES;
@@ -53,6 +57,8 @@ - (void)emitEvent:(NSString *)name body:(NSString *) body
5357
}
5458
- (void)emitEventDict:(NSString *)name body:(NSDictionary *) body
5559
{
60+
//TODO: All the FS events use the stream id as name. These events will be omitted since the streamID is not part of <supportedEvents>
61+
NSLog(@"emit dict start");
5662
NSError *error;
5763
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:body
5864
options:NSJSONWritingPrettyPrinted

0 commit comments

Comments
 (0)