Bulk promises with EmberJS
I needed not to chain promises but to resolve a whole bunch of them together. The documentation was sparse so it took me a while to stumble upon the solution (Ember.RSVP.all
). In case you need something like that here it is.
promises = someFancyStuff.map (resource) -> createPromise(resource)
Ember.RSVP.all(promises).then((results) -> doSomethingWithIt(results))
You can create an array of promises that you pass into Ember.RSVP.all
which passes an array of the results into the .then
chain. Actually quite simple. :-)
Written by Jens Grassel
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#