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

263
Views
Cómo devolver una Promesa de una función pasada a Deferred.pipe()

La siguiente cadena debe ejecutarse secuencialmente.

 $.when() .pipe(functionA) .pipe(functionB) .fail(functionC);

donde functionA devuelve una Promesa.

 function functionA() { return networkCall().then(sideEffectsForSuccess).catch(sideEffectsForFailure); } function networkCall() { return new Promise(function (resolve, reject) { return $.ajax(...); }); }

Sin embargo, esto no parece funcionar, ya que functionB B se ejecuta inmediatamente sin esperar a que la Promesa devuelta por la función A se resuelva (o falle). La cadena funciona correctamente si functionA A se cambia a

 function functionA() { return $.ajax(...).pipe(sideEffectsForSuccess, sideEffectsForFailure); }

Desafortunadamente, tengo que usar networkCall . ¿Alguna idea de cómo hacer que esto funcione?

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

0

¿Puedes devolver la promesa?

 function functionA() { let callPromise = networkCall(); callPromise.then(sideEffectsForSuccess).catch(sideEffectsForFailure); return callPromise; }
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!