Angular merge 不会触发 switchMap 中的所有 observable

Angular merge does not fire all observables within switchMap

我正在 switchMap 运算符中合并两个 observable,但我的问题是只有一个 observable 触发。我的代码

    formArray.valueChanges
        .pipe(
            takeUntil( this._unsubscribeAll ),
            switchMap( sm => {
                const tempAnswerChanges$: Observable<any>[] = formArray.controls.map( ( c, i ) => {
                    return c.get( 'answer' ).valueChanges
                        .pipe(
                            tap( response => {
                                this.value = !this.value
                                formArray.controls[ 2 ].patchValue( { display: this.value }, { emitEvent: true } )
                                console.log(formArray.controls[ 2 ].value)
                            } ),
                        )
                } );
                const tempDisplayChanges$: Observable<any>[] = formArray.controls.map( ( c, i ) => {
                    return c.get( 'display' ).valueChanges
                        .pipe(
                            tap( response => {
                                console.log('Display Has changed',response)
                            } ),
                        )
                } );
                return merge(...tempDisplayChanges$, tempAnswerChanges$ );
            } ),
        ).subscribe();

在示例中,如果将合并语句更改为

  return merge(...tempAnswerChanges$, tempDisplayChanges$ );

然后 tempAnswerChanges$ 触发,而 tempDisplayChanges$ 永远不会触发。我不明白为什么

试试这个:

return merge(...tempAnswerChanges$, ...tempDisplayChanges$ );