Basically I am trying to create a promise queue in angular that works kind of like $q.all()
does, except that it allows me to push more promises onto the array after $q.all()
has been executed for example.
To try and explain better, imagine giving a function a single promise for which you want to execute some code for then()
. However while you are waiting for this first promise to resolve, you give a second promise to the function. Now I don't want then()
being called until both have completed (similar to $q.all()
). If the first promise completes before the second is provided, the then()
function would be called twice. This should work for an arbitrary number of promises.
Essentially you end up with a promise queue, that executes then()
once for every time the queue has been emptied (i.e. all currently provided promises have been resolved). I'm sure I could figure out a nice way to do this, just seeing if anyone in SO town has already implemented something, or there is an easy option I am missing.