Skip to content

Commit 0c2c9b5

Browse files
committed
Add amb variant to RxScala
1 parent 00b7116 commit 0c2c9b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3866,6 +3866,18 @@ object Observable {
38663866
))
38673867
}
38683868

3869+
/**
3870+
* Mirror the one Observable in an Iterable of several Observables that first emits an item.
3871+
*
3872+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/amb.png">
3873+
*
3874+
* @param sources an Iterable of Observable sources competing to react first
3875+
* @return an Observable that emits the same sequence of items as whichever of the source Observables
3876+
* first emitted an item
3877+
*/
3878+
def amb[T](sources: Iterable[Observable[T]]): Observable[T] = {
3879+
toScalaObservable[T](rx.Observable.amb(sources.map(_.asJavaObservable.asInstanceOf[rx.Observable[T]]).asJava))
3880+
}
38693881
}
38703882

38713883

0 commit comments

Comments
 (0)