Open jrdn91 opened 7 years ago
Hi @Jordan4jc , there is a feature of getting queue statistics which is undocumented in PR #2. I just released it as v0.2.0
.
With the { statistics: true }
option, you can access queueTotal
, queuePending
and queueIdle
from the queue instance.
var queue = $queueFactory(1, { statistics: true });
// enqueue just one task
queue.enqueue(function () {
console.log('finished the task');
$timeout(function () {
// after a while, task finished
console.log(queue.queuePending, queue.queueIdle); // 0, true
});
// task hasn't finished here
console.log(queue.queuePending, queue.queueIdle); // 1, false
});
I have a loop that pushes
$http
requests into a queue and the queue then runs waiting for each to finish before moving to the next which is fantastic. Upon starting this queue I open atoastr
on the page so the user knows something is happening in the background and then have some code in the success of each$http
call that looks like thisThis just checks to see if it's on the last ajax call for this given array being looped over and if it is, on success will clear the toast. It works but this feels clunky to me and I'm curious if there is a way not documented to listen to when a given queue has completed.
I tried watching the queue API instance but it didn't log anything at all