Rxjs 我如何调用两个方法,第一个返回void observable,第二个返回observable?

Rxjs 我如何调用两个方法,第一个返回void observable,第二个返回observable?,rxjs,Rxjs,我叫两个方法。 complete()返回void observable getDetails()返回可观察的 我打给地图上的第二个。 我不知道这是正确的方法还是有其他方法 我调用了complete()方法,该方法将标志更新为completed并返回void observable。我需要调用getDetails方法,它返回observable this.dataService.complete(input) .pipe( map(() => {this.dataService.ge

我叫两个方法。 complete()返回void observable getDetails()返回可观察的 我打给地图上的第二个。 我不知道这是正确的方法还是有其他方法

我调用了complete()方法,该方法将标志更新为completed并返回void observable。我需要调用getDetails方法,它返回observable

this.dataService.complete(input)
.pipe(  
   map(() => {this.dataService.getDetails(id)
                  .subscribe((result) => {
                        console.log(result);
                   })
       })
).subscribe();
我得到了预期的结果,但我是rxjs的初学者。 如果这是错误的,请让我知道正确的方法。
谢谢。

您应该避免嵌套订阅() 尝试使用
concatMap
mergeMap
switchMap
等继续流

this.dataService.complete(input)
.pipe(  
   switchMap(() => this.dataService.getDetails(id)),
   tap(result=>console.log(result))
).subscribe();