Search code examples
angularrxjsrxjs5

rxjs operator that will make http call but will ignore the data and will not return an observable


I would like to make a HTTP call and get the output as observable (this is the easy part) and then, immediately make another HTTP call and ignore the output.

I can not use switchMap operator because the second HTTP call does not return something useful. it just returns 'Done!' and the first call returns complex JSON that i need.

what I did, and it works, is to subscribe to the inner http call and i would like to know if there is an rxjs operator that i can use instead:

this.dataStorageBaseService.createIdentity(identity)
  .do(() => this.authService.JustSimpleHTTPCall().first().subscribe()).subscribe();       

Is there a RxJS operator that i can use instead of subscribe again to the "JustSimpleHTTPCall"? map would be good but i do not need the data that JustSimpleHTTPCall returns and it will not work together with the output of "createIdentity" that I need to return as observable.


Solution

  • You just need your inner Observable to emit the outer result - this can be done with concat

    this.dataStorageBaseService.createIdentity(identity)
      .switchMap(result => this.authService.JustSimpleHTTPCall().concat(Observable.of(result)))
      .subscribe(...);