Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.64 KB

toset.md

File metadata and controls

50 lines (39 loc) · 1.64 KB

Rx.Observable.prototype.toSet()

Creates an observable sequence with a single item of a Set created from the observable sequence. Note that this only works in an ES6 environment or polyfilled.

Returns

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

Example

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

var subscription = source.subscribe(
    function (x) {
        var arr = [];
        x.forEach(function (i) { arr.push(i); })
        console.log('Next: ' + arr);
    },
    function (err) {
        console.log('Error: ' + err);
    },
    function () {
        console.log('Completed');
    });

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

Location

File:

Dist:

NPM Packages:

NuGet Packages:

Unit Tests: