github Reactive-Extensions/RxJS v2.2.25
Reactive Extensions v2.2.25

latest releases: v4.1.0, v4.0.8, v4.0.7...
9 years ago

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

Don't miss a new RxJS release

NewReleases is sending notifications on new releases.