If the "all" Promises permission does not matter (for example, you are updating some elements on a page and you don't care if it is progressive, not just one whoosh), I created a simple TaskQueue service. He will not wait until all Promises are resolved, but he will process all the added Promises / Functions / Tasks that he will receive, and with max. concurrency configured limit value.
As soon as I found this and some other StackOverflow that didn't help with my problem. So now I give something back to the community, I think. Hope this helps someone.
It uses modern JS elements such as const and lambda expressions, but you can just compile it from a precompiler like babel if you just want the "old" one.
https://gist.github.com/Blackskyliner/8b1bafed326044fa4f8b1ba2627d1117
It just simply processes the turn after Tasks, which are simply anonymous functions, return a promise or value, are added. It will stick with the maxConcurrentTasks custom variable in the service.
If a task returns a promise, which returns a promise, and so on, it will always use the initial โslotโ in the queue. Thus, he will free the โslotโ for another added task after the whole chain of tasks is promised (or rejected).
source share