0

I have two service svcA, svcB. The svcA result is Observable<ObjA>. The svcB result is Observable<Array<ObjB>>. The svcA result is the parameter of the svcB. How can I implement this in a route resolver which result is Observable<Array<ObjB>>?

Unfortunately RxJs version is below 5.5

Thanks

frido
  • 13,065
  • 5
  • 42
  • 56
L. Kvri
  • 1,456
  • 4
  • 23
  • 41
  • Use switchMap to combine those two into one - svcA.pipe(switchMap(svcAResult => ...)) – user1111 Jun 08 '20 at 14:33
  • As I mentioned RxJs version below 5.5 so pipe not exists because introduced in 5.5. If I remember good. I would like to use the svcA result as parameter in svcB – L. Kvri Jun 08 '20 at 16:04
  • Does this answer your question? [Angular - Make multiple HTTP calls sequentially](https://stackoverflow.com/questions/51212448/angular-make-multiple-http-calls-sequentially) – frido Jun 08 '20 at 16:04
  • In RXjs below 6, is `svcA.switchMap(res=>svcB(res))` just "remove" pipe, see https://rxjs-dev.firebaseapp.com/guide/v6/migration#pipe-syntax – Eliseo Jun 08 '20 at 16:11

1 Answers1

0

You want to use the observable chain instead of pipe if the version is below 5.5

svcA
  .doMyJob()
  .switchMap(resultFromA => svcB.doMyJob(resultFromA))
Xinan
  • 3,002
  • 1
  • 16
  • 18