Back to Rxjs

This is RxJS v 4. Find the latest version here

doc/api/core/operators/concatproto.md

4.1.02.6 KB
Original Source

This is RxJS v 4. Find the latest version here

Rx.Observable.prototype.concat(...args)

Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.

Arguments

  1. args (arguments | Array): An array or arguments of Observable sequences.

Returns

(Observable): An observable sequence that contains the elements of each given sequence, in sequential order.

Example

js
var source = Rx.Observable
    .return(42)
    .concat(Rx.Observable.return(56), Rx.Observable.return(72));

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

// => Next: 42
// => Next: 56
// => Next: 72
// => Completed

// With a promise
var source = Rx.Observable.just(42)
    .concat(Promise.resolve(42));

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

// => Next: 42
// => Next: 42
// => Completed

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests: