Back to Rxjs

This is RxJS v 4. Find the latest version here

doc/api/core/operators/toarray.md

4.1.01.9 KB
Original Source

This is RxJS v 4. Find the latest version here

Rx.Observable.prototype.toArray()

Creates a list from an observable sequence.

Returns

(Observable): An observable sequence containing a single element with a list containing all the elements of the source sequence.

Example

js
var source = Rx.Observable.timer(0, 1000)
    .take(5)
    .toArray();

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

// => Next: [0,1,2,3,4]
// => Completed

Location

File:

Dist:

Prerequisites:

  • None

NPM Packages:

NuGet Packages:

Unit Tests: