if i have a list of available downloads (app interface), i'm able to begin the download of each one even if another hasn't finished, but, if i cancel one that has not really started downloading (onBegin callback has not being called), i get an error because i still don't have the actual jobId.
i think that if we get the job id when we just started the download, this could be fixed, is it possible?
@CesarLanderos We could return the jobId synchronously.
So instead of returning just the promise, we could return something like:
{
jobId: 1,
promise: <Promise>
}
What do you think? We're in the process of releasing V2, so now is the time to be making breaking changes such as this one. :-)
Great!, and yeah!, definitely most be asynchronous, but with this approach, i have just one concern, its not really bad.
I am working in an app in wich a user can download certain contents, each content has many files to download, so i make use (extensively) of Promise.all()
For example:
Promise.all(files.map(file =>
RNFS.download(options)
))
.then(results =>
// done
);
But well, i will just have to make some adjustments to the map function, it will not be as clean as before, but is cleaner that the workaround that i had to make, than consisted on deleting the content from the downloaded contents db, and when the onBegin callback gets called, i check if the content still exists in the db, if not then immediately stops the download, it is not very semantic to be honest :p
Typo!, must be synchronous, not asynchronous hehe.
Most helpful comment
Added this in https://github.com/johanneslumpe/react-native-fs/commit/5af22b2782515ed2b21280a6c55b716d235a96bd