Typescript 是否可以在没有forkJoin或CombineTest的情况下访问管道变量?

Typescript 是否可以在没有forkJoin或CombineTest的情况下访问管道变量?,typescript,rxjs,combinelatest,Typescript,Rxjs,Combinelatest,在RxJs设备中,由于值累积,无法使用forkJoin()或combinelatetest()时,如果没有嵌套管道,是否可以访问以前的管道变量 或者在下面的场景中,使用switchMap()的嵌套管道是否还可以 // this.incrementNavigation$ emits always 1 // this.decrementNavigation$ emits always -1 this.searchSuggestions$.pipe( // Can't use combineLa

在RxJs设备中,由于值累积,无法使用
forkJoin()
combinelatetest()
时,如果没有嵌套管道,是否可以访问以前的管道变量

或者在下面的场景中,使用
switchMap()
的嵌套管道是否还可以

// this.incrementNavigation$ emits always 1
// this.decrementNavigation$ emits always -1

this.searchSuggestions$.pipe(
  // Can't use combineLatest() due to accumulation happening in scan()
  switchMap(search => {
    return merge(this.incrementNavigation$, this.decrementNavigation$).pipe( // Nesting begins...
      startWith(0),
      scan((acc: number, cur: number) => {
        if (acc+cur < 0) return search.length-1 // Need access to search variable
        if (acc+cur > search.length-1) return 0
        return acc+cur
      }),
    )
  })
).subscribe(pos => {
  this.searchNavigationPosition = pos
})
//this.incrementNavigation$始终发射1
//这个.递减导航$总是发射-1
此.searchs.pipe(
//由于扫描()中发生累积,无法使用combineLatest()
开关映射(搜索=>{
返回合并(this.incrementNavigation$,this.decrementNavigation$).pipe(//嵌套开始。。。
startWith(0),
扫描((acc:编号,cur:编号)=>{
if(acc+cur<0)返回search.length-1//需要访问搜索变量
如果(acc+cur>search.length-1)返回0
返回acc+cur
}),
)
})
).订阅(pos=>{
this.searchNavigationPosition=pos
})

嵌套
pipe()
调用有什么问题?是问题吗。我已经读了很多文章,说不应该这样做。你确定你没有混淆管道和嵌套订阅吗?我怀疑是否有人建议不要使用嵌套管道。你的管道看起来很好。我不会用管道嵌套超过一个或两个级别(几乎总是有办法这样做),但通常希望至少有一个级别的嵌套
管道
。这在处理错误时变得最为明显。