2

Theoretically, I know what mergeMap is and how it works, but when I try to understand using practical approach I get confused, this is what I have done so far

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}))})
        )   

unfortunately, I am getting undefined when I try to merge them, your help would be appreciated to make me understand how it works.

2
  • you don't have a return in your pipe return ch+' '+data1
    – rhavelka
    Aug 19, 2020 at 16:57
  • can you show me how? Aug 19, 2020 at 17:25

1 Answer 1

2

You are not returning anything in your second pipe

Try this

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

2
  • Thank you @Bogdan Chereghi, I gave you +1 and accepted as an answer Aug 19, 2020 at 17:35
  • @RussianFederation Thank you Aug 19, 2020 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.