Skip to content

Commit

Permalink
Merge pull request #842 from RZulfikri/fix/download-event
Browse files Browse the repository at this point in the history
add condition inside download event, before pass it to event callback.
  • Loading branch information
itinance authored Feb 5, 2020
2 parents aa079a5 + 762d29d commit ce71cba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions FS.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,21 @@ var RNFS = {
var subscriptions = [];

if (options.begin) {
subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadBegin', options.begin));
subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadBegin', (res) => {
if (res.jobId === jobId) options.begin(res);
}));
}

if (options.progress) {
subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadProgress', options.progress));
subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadProgress', (res) => {
if (res.jobId === jobId) options.progress(res);
}));
}

if (options.resumable) {
subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadResumable', options.resumable));
subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadResumable', (res) => {
if (res.jobId === joibId) options.resumable(res);
}));
}

var bridgeOptions = {
Expand Down

0 comments on commit ce71cba

Please sign in to comment.