-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-native-queue + react-native-background-upload for a bunch of file uploads #29
Comments
On success of each file, I'm updating my database and redux store (Not
sure If I can do that in a job).
You can run any arbitrary code in a job. If a job has to be run in the
background (ie a background task) you will need to bootstrap the app when
the job kicks off in order to update your app database/redux store I
imagine. Which is perfectly fine. The main thing is remember background
tasks are limited to ~30 seconds cross platform so ensure your job can
complete in that time frame (or break it up into separate tasks).
Reading your docks, I'm unsure if your lib will keep executing one job
after the other in background, or If I have to use it along with another
lib, such as background tasks.
The queue will continue processing until the queue is empty or the queue
lifespan is reached in whatever thread you start it up in. If it's your
main app thread then it will process until complete so long as user is
focused in your app, if you set up background tasks to run every ~15 min
and start churning through the queue then the queue will fire up and start
processing jobs in the background task for roughly ~25-30 sec (depending on
queue lifespan) every ~15 min.
Put another way, the queue is a general tool for job management. If you
start processing jobs in your main app, it will process there. But since
it's a general tool, there's no reason you can't fire up the queue in a
background task (https://github.com/jamesisaac/react-native-background-task)
or in a worker thread (https://github.com/devfd/react-native-workers). RNQ
plays well with others, you can pretty much use it anywhere as you see fit.
I tried to experiment creating a dozen jobs that just wait 5 seconds and
print something on the screen. When I went into background, they paused,
nothing was appearing on the screen.
If you are running the queue in your main app thread, then you have to be
focused on the app for the code to execute. It sounds like you want these
jobs to be processed in the background, in that case you will need to
integrate some kind of background task library like (
https://github.com/jamesisaac/react-native-background-task).
Hope this helps!
--------------------------------------------
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
…On Sat, Jun 30, 2018 at 6:18 PM Otávio Gaião ***@***.***> wrote:
Hi. I'm using your lib in my new app, and I have some questions that I
hope someone here can help me with.
In my app, I have a "sync" routine, where I make many api calls
sequencially. Each api call is a file that I'm sending. For that I'm
thinking about using react-native-background-upload, since the upload has
to continue if the app goes into background.
I'm using your lib to make a queue of files to send. So my logic is the
following:
Create queue()
AddWorker()
for(file of files) {
createJob(file)
}
On success of each file, I'm updating my database and redux store (Not
sure If I can do that in a job).
Reading your docks, I'm unsure if your lib will keep executing one job
after the other in background, or If I have to use it along with another
lib, such as background tasks.
I tried to experiment creating a dozen jobs that just wait 5 seconds and
print something on the screen. When I went into background, they paused,
nothing was appearing on the screen.
Could someone clarify that for me? Thanks!!!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#29>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABxTU0AxVElrVfRBU60w4T1Ijz20gWrpks5uB_lIgaJpZM4U-Huj>
.
|
Nice man, It helped a lot! Thank you so much! |
Oh one more question. Is there any way to tell the queue a job ended? Because the file upload is being made in a service or something like that. So the queue invokes the upload and think its over, so it goes to the next one. |
It sounds like you are making an async call and then not waiting for it to
finish before ending the job.
Make the job handler function an async function then await on your
asynchronous call so the code execution pauses.
Alternatively if you need to check if the upload has finished pricesiyou
will have to implement some sort of polling solution.
If I am interpreting you incorrectly and you just want to know when a job
completes you can hook into a life cycle call back for that.
https://github.com/billmalarky/react-native-queue/blob/master/README.md#options-and-job-lifecycle-callbacks
…On Tue, Jul 3, 2018, 6:31 AM Otávio Gaião ***@***.***> wrote:
Oh one more question. Is there any way to tell the queue a job ended?
Because the file upload is being made in a service or something like that.
So the queue invokes the upload and think its over, so it goes to the next
one.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABxTU5-vv7hEIzuyi0HZiqxzTKqAncKtks5uC0fzgaJpZM4U-Huj>
.
|
Thank you man! I will try that. |
No prob!
…On Wed, Jul 4, 2018, 12:47 PM Otávio Gaião ***@***.***> wrote:
Thank you man! I will try that.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABxTU92xSFNA9QuwMrRFIrOSicfCZxOdks5uDPGXgaJpZM4U-Huj>
.
|
Hi, I used the same logic of @otaviogaiao, but I can not make the API call sequentially. In fact I want to make the API call sequential. Could someone clarify that for me? Thanks!!! |
ping @billmalarky |
ping @otaviogaiao |
Hi. I'm using your lib in my new app, and I have some questions that I hope someone here can help me with.
In my app, I have a "sync" routine, where I make many api calls sequencially. Each api call is a file that I'm sending. For that I'm thinking about using react-native-background-upload, since the upload has to continue if the app goes into background.
I'm using your lib to make a queue of files to send. So my logic is the following:
On success of each file, I'm updating my database and redux store (Not sure If I can do that in a job).
Reading your docks, I'm unsure if your lib will keep executing one job after the other in background, or If I have to use it along with another lib, such as background tasks.
I tried to experiment creating a dozen jobs that just wait 5 seconds and print something on the screen. When I went into background, they paused, nothing was appearing on the screen.
Could someone clarify that for me? Thanks!!!
The text was updated successfully, but these errors were encountered: