diamondio/better-queue

Pushing tasks from within queue function

joystick opened this issue · 0 comments

Hi, I'm trying to push task to queue from within queue function, e.g.

App = {}

const fn(data) {
  if (data.text === 'close_all') {
    const all = getAll()
    all.forEach(one => {
      App.q.push({ text: 'close_one', one })
    })
  }
  if (data.text === 'close_one') {
    closeOne(data.one)
  }
}

App.q = new Queue(fn)
App.q.push({ text: 'close_all' })

close_one processed normally, close_all - not.

Is there anything I need to do to make it work as desired please?

Thank you,
Alex