Skip to content
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

Any way to handle a dynamic input? #60

Open
erikian opened this issue Jul 12, 2021 · 0 comments
Open

Any way to handle a dynamic input? #60

erikian opened this issue Jul 12, 2021 · 0 comments
Labels

Comments

@erikian
Copy link

erikian commented Jul 12, 2021

Hello, I'm building an upload queue and I'd like to know if it's possible to add more files after calling throat, e.g.:
`

let uploadedFiles = 0
const throat = require('throat')(10)

// uploadQueue initially has 20 files
for (const upload of uploadQueue) {
  throat(async () => {
    // logic for processing upload
    uploadedFiles++;
    console.log({ uploadedFiles, remainingFiles: uploadQueue.length - uploadedFiles })
  })
}

// add another file to the queue
uploadQueue.push(newUpload)

In the above example, I get { uploadedFiles: 20, remainingFiles: 1 } after the initial 20 files are processed and the queue never gets to the new upload. Is there any way to listen to changes in uploadQueue? Or do I have to call throat again every time I add more items to the queue?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant