簡體   English   中英

在 Rxjs 中使用 mergeMap 時未定義 output

[英]undefined output while using mergeMap in Rxjs

從理論上講,我知道什么是 mergeMap 以及它是如何工作的,但是當我嘗試使用實際方法來理解時,我會感到困惑,這就是我到目前為止所做的

const input1$= of("value 1","value 2","value 3");
const input2$= of(1,2,3,4);
const obs=input1$.pipe(
            mergeMap(data1=>{
              return input2$
              .pipe(map(ch=>{ch+' '+data1}))})
        )   

不幸的是,當我嘗試合並它們時,我變得不確定,如果您能幫助我了解它是如何工作的,我們將不勝感激。

您沒有在第二個 pipe 中返回任何內容

嘗試這個

 const obs=input1$.pipe( mergeMap(data1=>{ return input2$.pipe(map(ch=>{ return ch+' '+data1 }))}) )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM