Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda