Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  89] [ 3]  / answers: 1 / hits: 19380  / 9 Years ago, mon, june 1, 2015, 12:00:00

I'm using babel to transpile my [email protected] code and I'm stuck with promises.



I need allSettled-type functionality that I could use in q and bluebird or angular.$q for example.



On babel's core-js Promise, there is no allSettled method.



Currently I'm using q.allSettled as a workaround:



import { allSettled } from 'q';



Is there something like that in babel polyfill? Alternatively, which is a good algorithm for me to try to implement?


More From » node.js

 Answers
11

Alternatively, which is a good algorithm for me to try to implement?





  1. create a new promise with an executor function

  2. use a counter/result array in the scope of the executor

  3. register a then() callback with each parent promise saving the results in the array

  4. resolve/reject promise from step 1 when counter indicates that all parent promises are done


[#66387] Friday, May 29, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myakylas

Total Points: 66
Total Questions: 85
Total Answers: 95

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
myakylas questions
Thu, Apr 28, 22, 00:00, 2 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sat, Sep 19, 20, 00:00, 4 Years ago
;