Skip to content

Commit

Permalink
add condition inside download event, before pass it to event callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
RZulfikri committed Feb 3, 2020
1 parent 8c08573 commit 762d29d
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 762d29d

Please sign in to comment.