Skip to content

Commit 4d0b301

Browse files
committed
Change 'window(closings: () => Observable[Any])' to 'window(boundary: => Observable[Any])'
1 parent 498c9dc commit 4d0b301

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -656,21 +656,20 @@ trait Observable[+T]
656656

657657
/**
658658
* Creates an Observable which produces windows of collected values. This Observable produces connected
659-
* non-overlapping windows. The current window is emitted and replaced with a new window when the
660-
* Observable produced by the specified function produces an object.
661-
* The function will then be used to create a new Observable to listen for the end of the next
662-
* window.
659+
* non-overlapping windows. The boundary of each window is determined by the items emitted from a specified
660+
* boundary-governing Observable.
663661
*
664-
* @param closings
665-
* The function which is used to produce an [[rx.lang.scala.Observable]] for every window created.
666-
* When this [[rx.lang.scala.Observable]] produces an object, the associated window
667-
* is emitted and replaced with a new one.
668-
* @return
669-
* An [[rx.lang.scala.Observable]] which produces connected non-overlapping windows, which are emitted
670-
* when the current [[rx.lang.scala.Observable]] created with the function argument produces an object.
662+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/window8.png" />
663+
*
664+
* @param boundary an Observable whose emitted items close and open windows. Note: This is a by-name parameter,
665+
* so it is only evaluated when someone subscribes to the returned Observable.
666+
* @return An Observable which produces connected non-overlapping windows. The boundary of each window is
667+
* determined by the items emitted from a specified boundary-governing Observable.
671668
*/
672-
def window(closings: () => Observable[Any]): Observable[Observable[T]] = {
673-
val func : Func0[_ <: rx.Observable[_ <: Any]] = closings().asJavaObservable
669+
def window(boundary: => Observable[Any]): Observable[Observable[T]] = {
670+
val func = new Func0[rx.Observable[_ <: Any]]() {
671+
override def call(): rx.Observable[_ <: Any] = boundary.asJavaObservable
672+
}
674673
val o1: rx.Observable[_ <: rx.Observable[_]] = asJavaObservable.window[Any](func)
675674
val o2 = Observable.items(o1).map((x: rx.Observable[_]) => {
676675
val x2 = x.asInstanceOf[rx.Observable[_ <: T]]

language-adaptors/rxjava-scala/src/test/scala/rx/lang/scala/CompletenessTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class CompletenessTest extends JUnitSuite {
160160
"toList()" -> "toSeq",
161161
"toSortedList()" -> "[Sorting is already done in Scala's collection library, use `.toSeq.map(_.sorted)`]",
162162
"toSortedList(Func2[_ >: T, _ >: T, Integer])" -> "[Sorting is already done in Scala's collection library, use `.toSeq.map(_.sortWith(f))`]",
163-
"window(Func0[_ <: Observable[_ <: TClosing]])" -> "window(() => Observable[Any])",
163+
"window(Observable[U])" -> "window(=> Observable[Any])",
164+
"window(Func0[_ <: Observable[_ <: TClosing]])" -> "window(=> Observable[Any])",
164165
"window(Observable[_ <: TOpening], Func1[_ >: TOpening, _ <: Observable[_ <: TClosing]])" -> "window(Observable[Opening], Opening => Observable[Any])",
165166
"window(Long, Long, TimeUnit)" -> "window(Duration, Duration)",
166167
"window(Long, Long, TimeUnit, Scheduler)" -> "window(Duration, Duration, Scheduler)",
@@ -350,7 +351,6 @@ class CompletenessTest extends JUnitSuite {
350351
println( "----------------------------------------------\n")
351352

352353
val actualMethods = getPublicInstanceAndCompanionMethods(typeOf[rx.lang.scala.Observable[_]]).toSet
353-
actualMethods.toList.sorted.foreach(println)
354354
var good = 0
355355
var bad = 0
356356
for ((javaM, scalaM) <- SortedMap(correspondence.toSeq :_*)) {

0 commit comments

Comments
 (0)