When you pass a number of source Observables to Amb, it will pass through the
emissions and notifications of exactly one of these Observables: the first one that sends a notification to
Amb, either by emitting an item or sending an onError
or
onCompleted
notification. Amb will ignore and discard the
emissions and notifications of all of the other source Observables.
TBD
TBD
RxGroovy implements this operator as amb
. It takes up to nine Observables
as individual parameters, or a single Iterable of Observables. There is also an instance
version of the operator, ambWith
, so that, for example, instead of writing
Observable.amb(o1,o2)
you could also write o1.ambWith(o2)
for the
same effect.
This operator does not by default operate on any particular Scheduler.
amb(Iterable)
amb(Observable,Observable)
(there are also versions that take up to nine Observable parameters)ambWith(Observable)
RxJava implements this operator as amb
. It takes up to nine Observables as
individual parameters, or a single Iterable of Observables. There is also an instance
version of the operator, ambWith
, so that, for example, instead of writing
Observable.amb(o1,o2)
you could also write o1.ambWith(o2)
for the
same effect.
This operator does not by default operate on any particular Scheduler.
amb(Iterable)
amb(Observable,Observable)
(there are also versions that take up to nine Observable parameters)ambWith(Observable)
RxJS implements this operator as amb
. It takes a variable number of parameters,
which may be either Observables or Promises (or combinations of the two).
/* Using Observable sequences */ var source = Rx.Observable.amb( Rx.Observable.timer(500).select(function () { return 'foo'; }), Rx.Observable.timer(200).select(function () { return 'bar'; }) ); var subscription = source.subscribe( function (x) { console.log('Next: ' + x); }, function (err) { console.log('Error: ' + err); }, function () { console.log('Completed'); });
Next: bar Completed
/* Using Promises and Observables */ var source = Rx.Observable.amb( RSVP.Promise.resolve('foo') Rx.Observable.timer(200).select(function () { return 'bar'; }) ); var subscription = source.subscribe( function (x) { console.log('Next: ' + x); }, function (err) { console.log('Error: ' + err); }, function () { console.log('Completed'); });
Next: foo Completed
TBD
TBD
TBD
TBD
TBD