This is RxJS v 4. Find the latest version here
Propagates the observable sequence that reacts first.
right
(Observable
): Observable sequence to match with the current sequence.
(Pattern
): Pattern object that matches when both observable sequences have an available value.
// Choice of either plan, the first set of timers or second set
var source = Rx.Observable.when(
Rx.Observable.timer(200).and(Rx.Observable.timer(300)).thenDo(function (x, y) { return 'first'; }),
Rx.Observable.timer(400).and(Rx.Observable.timer(500)).thenDo(function (x, y) { return 'second'; })
);
var subscription = source.subscribe(
function (x) {
console.log('Next: ' + x);
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
});
// => Next: first
// => Next: second
// => Completed
File:
Dist:
Prerequisites:
NPM Packages:
NuGet Packages:
Unit Tests: