console . log ( `mergeMap.ts` ) ; import { of , from , Observable } from "rxjs" ; import { map , mergeMap , delay , concatMap } from "rxjs/operators" ; interface IProductId { id : number ; } interface IProductDescription { name : string ; description : string ; } const productList = < Observable < IProductId > > from ( [ { id : 1 } , { id : 2 } , { id : 3 } ] ) ; function getProductName ( id ) { return of ( { id : id , name : `Product_${ id }` , description : `Description_${ id }` } ) ; } productList . pipe ( map ( ( value ) => { console . log ( `Product id: ${ value . id }` ) ; return getProductName ( value . id ) ; } ) ) . subscribe ( ( value ) => { value . subscribe ( ( value ) => { console . log ( `product name : ${ value . name }` ) ; console . log ( `product desc : ${ value . description }` ) ; } ) ; } ) ; productList . pipe ( mergeMap ( ( value ) : Observable < IProductDescription > => { console . log ( `Product id: ${ value ?. id }` ) ; return getProductName ( value . id ) ; } ) ) . subscribe ( ( value ) => { console . log ( `product name : ${ value . name }` ) ; console . log ( `product desc : ${ value . description }` ) ; } ) ; const emitTreeTwoOne = of ( 3 , 2 , 1 ) ; const delayedEmit = emitTreeTwoOne . pipe ( concatMap ( ( value ) => { console . log ( `>> emit >> 
        ${ new Date ( ) . toLocaleTimeString ( ) } 
        value : ${ value }, 
        delaying : ${ 1000 * value } ms` ) ; return of ( value ) . pipe ( delay ( 1000 * value ) ) ; } ) ) ; delayedEmit . subscribe ( value => { console . log ( `<< receive << 
        ${ new Date ( ) . toLocaleTimeString ( ) } 
        received value : ${ value }` ) ; } ) ;