Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Reactive Extensions v2.2.25

Compare
Choose a tag to compare
@mattpodwysocki mattpodwysocki released this 05 Jun 06:46
· 1873 commits to master since this release

This is a minor update from RxJS version 2.2.24 which includes the following changes including new operators of concatMap or its alias selectConcat

ConcatMap/SelectConcat

A new operator was introduced to help chain together serial asynchronous operations and preserve order called concatMap or its alias selectConcat. This operator in its intent is nothing more than map(...).concat(). In contrast with flatMap or its alias selectMany, is nothing more than map(...).merge() where order is not preserved in order, but instead as to the time that the observable responds.

Below is an example of its usage.

var source = Rx.Observable.range(0, 5)
    .concatMap(function (x, i) {
        return Rx.Observable
            .interval(100)
            .take(x).map(function() { return i; }); 
    });

var subscription = source.subscribe(
    function (x) {
        console.log('Next: ' + x);
    },
    function (err) {
        console.log('Error: ' + err);   
    },
    function () {
        console.log('Completed');   
    });

// => Next: 1 
// => Next: 2 
// => Next: 2 
// => Next: 3 
// => Next: 3 
// => Next: 3 
// => Next: 4 
// => Next: 4 
// => Next: 4 
// => Next: 4 
// => Completed 

Also, note that just like flatMap and selectMany, these methods also accept JavaScript Promises as inputs.

var source = Rx.Observable.fromArray([1,2,3,4])
    .concatMap(function (x, i) {
        return Promise.resolve(x + i);
    });

var subscription = source.subscribe(
    function (x) {
        console.log('Next: ' + x);
    },
    function (err) {
        console.log('Error: ' + err);   
    },
    function () {
        console.log('Completed');   
    });

// => Next: 4
// => Next: 4 
// => Next: 4 
// => Next: 4 
// => Completed   

Closed Issues

  • #172 - Passing Handlers to Ember
  • #171 - selectConcat / concatMap in docs but not in NPM
  • #170 - Fix path for Alphabet Invasion example