Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

javascript - Rxjs - How to call two httpService after combinelatest?

I don't know if it's the better solution but I need a function that subscribes to two ngrx selectors and use it as parameters for two http services and I used combineLatest:

  combineLatest([this.selectedCompany$, this.account$]).subscribe(res => {
  this.idCompany = res[0]!.id;
  this.account = res[1];
  this.getDashboardCardService(this.account!.id.toString(), this.idCompany.toString(), 'time');
  this.getavailableSpaceService(this.idCompany).subscribe(res => {
      this.space = res;
  })

}).unsubscribe();

I use combineLatest to subscribe to two ngrx selectors and in subscribe I need to use these values for doing two http calls, getDashboardCard and available. It works but I don't like it...which is the better solution for doing it?

question from:https://stackoverflow.com/questions/66052738/rxjs-how-to-call-two-httpservice-after-combinelatest

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In short, You should make .pipe( after combineLatestand inside that pipe use for example switchMap to be able to call another service.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...