@@ -656,21 +656,20 @@ trait Observable[+T]
656
656
657
657
/**
658
658
* 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.
663
661
*
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.
671
668
*/
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
+ }
674
673
val o1 : rx.Observable [_ <: rx.Observable [_]] = asJavaObservable.window[Any ](func)
675
674
val o2 = Observable .items(o1).map((x : rx.Observable [_]) => {
676
675
val x2 = x.asInstanceOf [rx.Observable [_ <: T ]]
0 commit comments