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

272
Views
How to return a Promise from a function passed to Deferred.pipe()

The following chain is to be executed sequentially

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

where functionA returns a Promise.

function functionA() {
  return networkCall().then(sideEffectsForSuccess).catch(sideEffectsForFailure);
}

function networkCall() {
  return new Promise(function (resolve, reject) {
    return $.ajax(...);
  });
}

However, this doesn't seem to work, since functionB gets immediately executed without waiting for the Promise returned from functionA to resolve (or fail). The chain works correctly if functionA is changed to

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

Unfortunately, I have to use networkCall. Any ideas how to make this work?

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

0

Can you return the promise

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!