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

561
Views
Múltiples llamadas Http en un @ngrx/effect

Estoy muy confundido y soy nuevo en @ngrx, así que perdónenme por no entender cómo se supone que funciona esto.

Digamos que tengo un efecto que se llama PlaceOrderEffect

En este sentido, quiero procesar cada solicitud en orden.

 processOrder$ = createEffect( ofType(OrderActions.PROCESS_ORDER), //here is where i get confused concatMap([ this.service.addCrust(), this.service.addTopings(), this.service.sendToCook() this.service.checkOut() ] )

¿Cómo puedo ejecutarlos en orden secuencial y manejar la respuesta final?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

concatMap es el operador RxJS que se usará con pipe , para fusionar la fuente observable con la nueva devuelta por concatMap , que no es su caso.

Creo que puede usar la función RxJS concat para lograr lo que está tratando de hacer si las solicitudes no dependen unas de otras, como la siguiente:

 processOrder$ = createEffect(() => this.actions$.pipe( ofType(OrderActions.PROCESS_ORDER), // here you need to switch and map to the new observable (concat one) returned by switchMapTo operator switchMap(({ payload }) => concat( this.service.addCrust(), this.service.addTopings(), this.service.sendToCook(), this.service.checkOut() ) ) ) );

Pero si cada solicitud depende de la anterior, puede usar el operador concatMap como el siguiente:

 processOrder$ = createEffect(() => this.actions$.pipe( ofType(OrderActions.PROCESS_ORDER), concatMap(({ payload }) => this.service.addCrust(payload)), concatMap((response1) => this.service.addTopings(response1)), concatMap((response2) => this.service.sendToCook(response2)), concatMap((response3) => this.service.checkOut(response3)) ) );
over 4 years ago · Santiago Trujillo 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!