Pergunta

Shortly about the task. We have an array of promises that could either resolve or reject. To understand whether total result is good or not - we need to know results of all promises in array.

In JQuery (our usual go-to library for promises) $.when.apply() works in a way that if one of the promises in array is rejected - main promise for the whole array is instantly rejected too, without waiting for all array element results, so this solution is not an option.

In Q library there's a .allSetteled() method that does the thing nicely. But I was wondering if there is some way to implement the same functionality using JQuery (because we're already using it in the project).

Any help appreciated! Thanks!

Foi útil?

Solução

Question is indeed similar to one mentioned in comment by Bergi: "You're right, there is no such method in jQuery. See my answer to the possible duplicate question $.Deferred: How to detect when every promise has been executed for a solution". In the link you can also fine couple of possible workarounds.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top