Combination Operators III

Observable as Monad!

Additional logic under the hood to compress the inner observable back into a single observable structure Paul P. Daniels & Luis Atencio, RxJS in Action
Nested Observable schema
Converts a higher-order Observable into a first-order Observable which concurrently delivers all values that are emitted on the inner Observables and applying a combination strategy (merge, concat)

mergeAll Operator

map + mergeAll = mergeMap

merge equivalent nested susbcription here & here


        rxjs.fromEvent(document, 'click')
            .pipe(
                rxjs.operators.map((ev) => rxjs.interval(900).pipe(rxjs.operators.take(5))),
                rxjs.operators.mergeAll()
            )
    
Flattens an Observable-of-Observable || Collect and subscribe to all observables

concatAll Operator

map + concatAll = concatMap

            rxjs.fromEvent(document, 'click')
                .pipe(
                    rxjs.operators.map((ev) => rxjs.interval(900).pipe(rxjs.operators.take(5))),
                    rxjs.operators.concatAll()
                )
        
Flattens an Observable-of-Observables by putting one inner Observable after the other || Collect observables and subscribe to next when previous completes

zipAll Operator


        const interval$ = rxjs.interval(1000)
        //when one inner observable completes no more values will be emitted
        rxjs.of(interval$, interval$.pipe(rxjs.operators.take(2)))
            .pipe(rxjs.operators.zipAll())
        

            let age$ = rxjs.of(27, 25, 29)
            let name$ = rxjs.of('Foo', 'Bar', 'Beer')
            let isDev$ = rxjs.of(true, true, false)
            // Here we compute the created value through a function in last parameter
            rxjs.of(age$, name$, isDev$)
                .pipe(
                    rxjs.operators.zipAll(),
                    rxjs.operators.delay(3000)
                )
        
Combines multiple Observables value from an Observable of Observable to create an Observable whose values are calculated from the values, in order, of each input Observables

Other Combination Operator