Skip to content

Any way to handle a dynamic input? #60

@erikian

Description

@erikian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions