I'm creating a function that sends off a bunch of promises and I want to let the user know what happened when they have all resolved. But, I'm not sure what parameters Ember.RSVP.all.then()
should take. Right now I have something like this:
Ember.RSVP.all(promises).then(
(success) ->
do stuff...
(error) ->
handle errors
)
But, I've also seen a pattern like this:
Ember.RSVP.all(promises).then(
(values) ->
do stuff...
).catch(
(values) ->
handle errors
)
Any clarification on this would be greatly appreciated. Thanks!
After an unfortunate flame war with an SO Soup Nazi and reading through the source of this undocumented method, I've finally figured out what is going on.
RSVP.all()
returns a promise so chaining then
onto it takes 2 functions as parameters(referred to as resolve()
and reject()
). The confusing part of this method is that resolve()
is passed an array of resolved promises where reject()
is passed the first promise that is rejected.