浏览代码

Merge pull request #381 from repodio/throw-on-cancel-android

Cancel download throw error bugfix (Android)
Travis Nuttall 5 年前
父节点
当前提交
104a94e3a9
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7
    0
      index.js

+ 7
- 0
index.js 查看文件

@@ -228,8 +228,14 @@ function fetch(...args:any):Promise {
228 228
     return fetchFile(options, method, url, headers, body)
229 229
   }
230 230
 
231
+  let promiseResolve;
232
+  let promiseReject;
233
+
231 234
   // from remote HTTP(S)
232 235
   let promise = new Promise((resolve, reject) => {
236
+    promiseResolve = resolve;
237
+    promiseReject = reject;
238
+
233 239
     let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'
234 240
 
235 241
     // on progress event listener
@@ -370,6 +376,7 @@ function fetch(...args:any):Promise {
370 376
     subscriptionUpload.remove()
371 377
     stateEvent.remove()
372 378
     RNFetchBlob.cancelRequest(taskId, fn)
379
+    promiseReject(new Error("canceled"))
373 380
   }
374 381
   promise.taskId = taskId
375 382