This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
Keep the listeners from the original tasks when checkForExistingDownloads is called #78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, this is definitely not a bug fix, just a suggestion :)
I know that the
checkForExistingDownloads
call is intended to only re-attach the lost downloads after the app is restarted somehow. But with this PR it could be easily extended to be able to control the currently running tasks without the need to keep all the task references in the application code. And still, you don't need to re-subscribe for the events after the tasks are resumed.In our use case, we started a download for a lot of files in parallel and recently added the feature for pausing the whole process. A solution would have been to track all the tasks ourselves and control those, but we realized that the tasks already in a map on the native side and also in another map on the JS side. By adding these couple extra lines we were able to keep the original listeners on the tasks (so we could monitor the progress) and retrieve the running tasks anytime without keeping track of them in our code.
Let me know what do think.