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

177
Vistas
forkJoin but next observable depends on the one before

https://www.learnrxjs.io/learn-rxjs/operators/combination/forkjoin

const example = forkJoin({
  // emit 'Hello' immediately
  sourceOne: of('Hello'),
  // emit 'World' after 1 second
  sourceTwo: of('World').pipe(delay(1000)),
  // throw error
  sourceThree: throwError('This will error')
}).pipe(catchError(error => of(error)));

// output: 'This will Error'
const subscribe = example.subscribe(val => console.log(val));

That's the main implementation but in my case, to call sourceTwo I need to use the data from sourceOne and the same with sourceThree. All calls need the previous observable in order to fetch data.

I only care about final result, don't need to merge anything, just do what this example does, show what sourceThree returns

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

forkJoin is intended to run calls in parallel, like Promise.all(). In your case, you cannot do that since the calls depend on each other.

Instead, you can pipe them. If you can parallelize 2 and 3, you can do something like the following.

sourceOne.pipe(
  res => forkJoin(makeCall2(res), makeCall3(res))
)

To complete the Promise comparison:

makeCall().then(res => Promise.all([
    makeCall2(res),
    makeCall3(res)
]));
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