Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Portando la funcionalidad de Promise.all de AngularJs a VueJs

¡Tengo esta función que necesito para pasar de AngularJs a VueJs y me tiene perplejo! Cualquier ayuda sería apreciada :)

 items = { one: {...details here...}, two: {}, }

AngularJs

 var promises = []; var deferred = $q.defer(); angular.forEach(items, function(details) { promises.push(details.promise); }); $q.all(promises).finally(function() { deferred.resolve(); }); return deferred.promise;

Lo que tengo en VueJs hasta ahora

 let promises = []; for (let [name, details] of Object.entries(items)) { promises.push(new Promise((resolve) => {resolve(details)})); } return Promise.all(promises);

¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No hay necesidad de una new Promise porque Promise.all permite valores que no son promesa.

Para una promesa que se resuelve con undefined (esto es lo que hace un diferido) cuando todos los valores de los objetos se liquidan (es decir, se resuelven o rechazan), es:

 Promise.all(Objects.values(items).map(({ promise }) => promise)) .then(() => {}) // if it's necessary to resolve with undefined .catch(() => {}) // if it's necessary to not reject

Si todos los valores no son promesas, no hay necesidad de Promise.all en absoluto.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!