Skip to content

Commit

Permalink
Merge pull request #381 from repodio/throw-on-cancel-android
Browse files Browse the repository at this point in the history
Cancel download throw error bugfix (Android)
  • Loading branch information
Traviskn authored Sep 26, 2019
2 parents 4305ef8 + da40583 commit 104a94e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,14 @@ function fetch(...args:any):Promise {
return fetchFile(options, method, url, headers, body)
}

let promiseResolve;
let promiseReject;

// from remote HTTP(S)
let promise = new Promise((resolve, reject) => {
promiseResolve = resolve;
promiseReject = reject;

let nativeMethodName = Array.isArray(body) ? 'fetchBlobForm' : 'fetchBlob'

// on progress event listener
Expand Down Expand Up @@ -370,6 +376,7 @@ function fetch(...args:any):Promise {
subscriptionUpload.remove()
stateEvent.remove()
RNFetchBlob.cancelRequest(taskId, fn)
promiseReject(new Error("canceled"))
}
promise.taskId = taskId

Expand Down

0 comments on commit 104a94e

Please sign in to comment.