|
@@ -109,19 +109,20 @@ function fetch(...args:any):Promise {
|
109
|
109
|
// create task ID for receiving progress event
|
110
|
110
|
let taskId = getUUID()
|
111
|
111
|
let options = this || {}
|
|
112
|
+ let subscription, subscriptionUpload
|
112
|
113
|
|
113
|
114
|
let promise = new Promise((resolve, reject) => {
|
114
|
115
|
let [method, url, headers, body] = [...args]
|
115
|
116
|
let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
|
116
|
117
|
|
117
|
118
|
// on progress event listener
|
118
|
|
- let subscription = emitter.addListener('RNFetchBlobProgress', (e) => {
|
|
119
|
+ subscription = emitter.addListener('RNFetchBlobProgress', (e) => {
|
119
|
120
|
if(e.taskId === taskId && promise.onProgress) {
|
120
|
121
|
promise.onProgress(e.written, e.total)
|
121
|
122
|
}
|
122
|
123
|
})
|
123
|
124
|
|
124
|
|
- let subscriptionUpload = emitter.addListener('RNFetchBlobProgress-upload', (e) => {
|
|
125
|
+ subscriptionUpload = emitter.addListener('RNFetchBlobProgress-upload', (e) => {
|
125
|
126
|
if(e.taskId === taskId && promise.onUploadProgress) {
|
126
|
127
|
promise.onUploadProgress(e.written, e.total)
|
127
|
128
|
}
|