Skip to content

Latest commit

 

History

History
67 lines (45 loc) · 1.72 KB

File metadata and controls

67 lines (45 loc) · 1.72 KB

{% if book.isPdf==true %}

amb

{% else %}

{% endif %}

Propagates the observable sequence or Promise that reacts first. "amb" stands for ambiguous.

Arguments

  1. args (Array|arguments): Observable sources or Promises competing to react first either as an array or arguments.

Returns

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

Example

{% if book.isPdf==true %}

var source = Rx.Observable.amb(
    Rx.Observable.timer(500).select(() => 'foo'),
    Rx.Observable.timer(200).select(() => 'bar')
);

var subscription = source.subscribe(
  x => console.log(`onNext: ${x}`),
  e => console.log(`onError: ${e}`),
  () => console.log('onCompleted'));

// => onNext: bar
// => onCompleted 
var source = Rx.Observable.amb(
    RSVP.Promise.resolve('foo'),
    Rx.Observable.timer(200).select(() => 'bar')
);

var subscription = source.subscribe(
  x => console.log(`onNext: ${x}`),
  e => console.log(`onError: ${e}`),
  () => console.log('onCompleted'));

// => onNext: foo
// => onCompleted

{% else %}

Using Observable sequences

Using Promises and Observables

{% endif %}