Skip to content

Commit 737f780

Browse files
committed
RxScala: Add latest to BlockingObservable
1 parent 8d75cd4 commit 737f780

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/observables/BlockingObservable.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,21 @@ class BlockingObservable[+T] private[scala] (val o: Observable[T])
243243
asJava.toIterable.asScala.toList: List[T] // useless ascription because of compiler bug
244244
}
245245

246+
/**
247+
* Returns an `Iterable` that returns the latest item emitted by this `BlockingObservable`,
248+
* waiting if necessary for one to become available.
249+
*
250+
* If this `BlockingObservable` produces items faster than `Iterator.next` takes them,
251+
* `onNext` events might be skipped, but `onError` or `onCompleted` events are not.
252+
*
253+
* Note also that an `onNext` directly followed by `onCompleted` might hide the `onNext` event.
254+
*
255+
* @return an `Iterable` that always returns the latest item emitted by this `BlockingObservable`
256+
*/
257+
def latest: Iterable[T] = {
258+
asJava.latest.asScala: Iterable[T] // useless ascription because of compiler bug
259+
}
260+
246261
}
247262

248263
// Cannot yet have inner class because of this error message:

0 commit comments

Comments
 (0)