0

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!

Majid Golshadi
  • 2,686
  • 2
  • 20
  • 29
North
  • 107
  • 1
  • 12
  • 3
    Please post what have you tried so far. – Dani Jan 09 '14 at 10:16
  • I didn't find any workable solution for such conditions in JQuery documentation. I've made sure that $.when.apply doesn't solve the problem (code used mostly from another [SO question](http://stackoverflow.com/questions/14777031/what-does-when-apply-somearray-do). – North Jan 09 '14 at 10:30

1 Answers1

0

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.

Community
  • 1
  • 1
North
  • 107
  • 1
  • 12