Back to Rxjs

This is RxJS v 4. Find the latest version here

doc/api/core/operators/ambproto.md

4.1.02.1 KB
Original Source

This is RxJS v 4. Find the latest version here

<a id="rxobservableprototypeambrightsource"></a>Rx.Observable.prototype.amb(rightSource)

<a href="#rxobservableprototypeambrightsource">#</a>

Propagates the observable sequence that reacts first.

Arguments

  1. rightSource (Observable): Second observable sequence.

Returns

(Observable): An observable sequence that surfaces either of the given sequences, whichever reacted first.

Example

js
var first = Rx.Observable.timer(300).map(function () { return 'first'; });
var second = Rx.Observable.timer(500).map(function () { return 'second'; });

var source = first.amb(second);

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

// => Next: first
// => Completed

Location

File:

Dist:

Prerequisites:

  • None

NPM Packages:

NuGet Packages:

Unit Tests: