@@ -353,10 +353,10 @@ trait Observable[+T]
353
353
* @return
354
354
* An [[rx.lang.scala.Observable ]] which produces buffers which are created and emitted when the specified [[rx.lang.scala.Observable ]]s publish certain objects.
355
355
*/
356
- def buffer [Opening , Closing ](openings : Observable [Opening ], closings : Opening => Observable [Closing ]): Observable [Seq [T ]] = {
356
+ def buffer [Opening ](openings : Observable [Opening ], closings : Opening => Observable [Any ]): Observable [Seq [T ]] = {
357
357
val opening : rx.Observable [_ <: Opening ] = openings.asJavaObservable
358
- val closing : Func1 [_ >: Opening , _ <: rx.Observable [_ <: Closing ]] = (o : Opening ) => closings(o).asJavaObservable
359
- val jObs : rx.Observable [_ <: java.util.List [_]] = asJavaObservable.buffer[Opening , Closing ](opening, closing)
358
+ val closing : Func1 [_ >: Opening , _ <: rx.Observable [_ <: Any ]] = (o : Opening ) => closings(o).asJavaObservable
359
+ val jObs : rx.Observable [_ <: java.util.List [_]] = asJavaObservable.buffer[Opening , Any ](opening, closing)
360
360
Observable .jObsOfListToScObsOfSeq(jObs.asInstanceOf [rx.Observable [_ <: java.util.List [T ]]])
361
361
}
362
362
@@ -540,9 +540,9 @@ trait Observable[+T]
540
540
* An [[rx.lang.scala.Observable ]] which produces connected non-overlapping windows, which are emitted
541
541
* when the current [[rx.lang.scala.Observable ]] created with the function argument produces an object.
542
542
*/
543
- def window [ Closing ] (closings : () => Observable [Closing ]): Observable [Observable [T ]] = {
544
- val func : Func0 [_ <: rx.Observable [_ <: Closing ]] = closings().asJavaObservable
545
- val o1 : rx.Observable [_ <: rx.Observable [_]] = asJavaObservable.window[Closing ](func)
543
+ def window (closings : () => Observable [Any ]): Observable [Observable [T ]] = {
544
+ val func : Func0 [_ <: rx.Observable [_ <: Any ]] = closings().asJavaObservable
545
+ val o1 : rx.Observable [_ <: rx.Observable [_]] = asJavaObservable.window[Any ](func)
546
546
val o2 = Observable .items(o1).map((x : rx.Observable [_]) => {
547
547
val x2 = x.asInstanceOf [rx.Observable [_ <: T ]]
548
548
toScalaObservable[T ](x2)
@@ -566,9 +566,9 @@ trait Observable[+T]
566
566
* @return
567
567
* An [[rx.lang.scala.Observable ]] which produces windows which are created and emitted when the specified [[rx.lang.scala.Observable ]]s publish certain objects.
568
568
*/
569
- def window [Opening , Closing ](openings : Observable [Opening ], closings : Opening => Observable [Closing ]) = {
569
+ def window [Opening ](openings : Observable [Opening ], closings : Opening => Observable [Any ]) = {
570
570
Observable .jObsOfJObsToScObsOfScObs(
571
- asJavaObservable.window[Opening , Closing ](openings.asJavaObservable, (op : Opening ) => closings(op).asJavaObservable))
571
+ asJavaObservable.window[Opening , Any ](openings.asJavaObservable, (op : Opening ) => closings(op).asJavaObservable))
572
572
: Observable [Observable [T ]] // SI-7818
573
573
}
574
574
@@ -1336,19 +1336,61 @@ trait Observable[+T]
1336
1336
* an observable that emits a single Closing when the group should be closed.
1337
1337
* @tparam K
1338
1338
* the type of the keys returned by the discriminator function.
1339
- * @tparam Closing
1340
- * the type of the element emitted from the closings observable.
1341
1339
* @return an Observable that emits `(key, observable)` pairs, where `observable`
1342
1340
* contains all items for which `f` returned `key` before `closings` emits a value.
1343
1341
*/
1344
- def groupByUntil [K , Closing ](f : T => K , closings : (K , Observable [T ])=> Observable [Closing ]): Observable [(K , Observable [T ])] = {
1345
- val fclosing : Func1 [_ >: rx.observables.GroupedObservable [K , _ <: T ], _ <: rx.Observable [_ <: Closing ]] =
1342
+ def groupByUntil [K ](f : T => K , closings : (K , Observable [T ])=> Observable [Any ]): Observable [(K , Observable [T ])] = {
1343
+ val fclosing : Func1 [_ >: rx.observables.GroupedObservable [K , _ <: T ], _ <: rx.Observable [_ <: Any ]] =
1346
1344
(jGrObs : rx.observables.GroupedObservable [K , _ <: T ]) => closings(jGrObs.getKey, toScalaObservable[T ](jGrObs)).asJavaObservable
1347
- val o1 = asJavaObservable.groupByUntil[K , Closing ](f, fclosing) : rx.Observable [_ <: rx.observables.GroupedObservable [K , _ <: T ]]
1345
+ val o1 = asJavaObservable.groupByUntil[K , Any ](f, fclosing) : rx.Observable [_ <: rx.observables.GroupedObservable [K , _ <: T ]]
1348
1346
val func = (o : rx.observables.GroupedObservable [K , _ <: T ]) => (o.getKey, toScalaObservable[T ](o))
1349
1347
toScalaObservable[(K , Observable [T ])](o1.map[(K , Observable [T ])](func))
1350
1348
}
1351
1349
1350
+ /**
1351
+ * Correlates the items emitted by two Observables based on overlapping durations.
1352
+ * <p>
1353
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/join_.png">
1354
+ *
1355
+ * @param other
1356
+ * the second Observable to join items from
1357
+ * @param leftDurationSelector
1358
+ * a function to select a duration for each item emitted by the source Observable,
1359
+ * used to determine overlap
1360
+ * @param rightDurationSelector
1361
+ * a function to select a duration for each item emitted by the inner Observable,
1362
+ * used to determine overlap
1363
+ * @param resultSelector
1364
+ * a function that computes an item to be emitted by the resulting Observable for any
1365
+ * two overlapping items emitted by the two Observables
1366
+ * @return
1367
+ * an Observable that emits items correlating to items emitted by the source Observables
1368
+ * that have overlapping durations
1369
+ * @see <a href="https://github.com/Netflix/RxJava/wiki/Combining-Observables#join">RxJava Wiki: join()</a>
1370
+ * @see <a href="http://msdn.microsoft.com/en-us/library/hh229750.aspx">MSDN: Observable.Join</a>
1371
+ */
1372
+ def join [S , R ] (
1373
+ other : Observable [S ],
1374
+ leftDurationSelector : T => Observable [Any ],
1375
+ rightDurationSelector : S => Observable [Any ],
1376
+ resultSelector : (T ,S ) => R
1377
+ ): Observable [R ] = {
1378
+
1379
+ val outer : rx.Observable [_ <: T ] = this .asJavaObservable
1380
+ val inner : rx.Observable [_ <: S ] = other.asJavaObservable
1381
+ val left : Func1 [_ >: T , _< : rx.Observable [_ <: Any ]] = (t : T ) => leftDurationSelector(t).asJavaObservable
1382
+ val right : Func1 [_ >: S , _< : rx.Observable [_ <: Any ]] = (s : S ) => rightDurationSelector(s).asJavaObservable
1383
+ val f : Func2 [_> : T , _ >: S , _ <: R ] = resultSelector
1384
+
1385
+ toScalaObservable[R ](
1386
+ outer.asInstanceOf [rx.Observable [T ]].join[S , Any , Any , R ](
1387
+ inner.asInstanceOf [rx.Observable [S ]],
1388
+ left. asInstanceOf [Func1 [T , rx.Observable [Any ]]],
1389
+ right.asInstanceOf [Func1 [S , rx.Observable [Any ]]],
1390
+ f.asInstanceOf [Func2 [T ,S ,R ]])
1391
+ )
1392
+ }
1393
+
1352
1394
/**
1353
1395
* Given an Observable that emits Observables, creates a single Observable that
1354
1396
* emits the items emitted by the most recently published of those Observables.
@@ -2136,18 +2178,15 @@ object Observable {
2136
2178
* <p>
2137
2179
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/empty.s.png">
2138
2180
*
2139
- * @param scheduler the scheduler to call the
2140
- [[rx.lang.scala.Observer#onCompleted onCompleted ]] method
2141
- * @param T the type of the items (ostensibly) emitted by the Observable
2142
2181
* @return an Observable that returns no data to the [[rx.lang.scala.Observer ]] and
2143
2182
* immediately invokes the [[rx.lang.scala.Observer ]]r's
2144
2183
* [[rx.lang.scala.Observer#onCompleted onCompleted ]] method with the
2145
2184
* specified scheduler
2146
2185
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#empty-error-and-never">RxJava Wiki: empty()</a>
2147
2186
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229066.aspx">MSDN: Observable.Empty Method (IScheduler)</a>
2148
2187
*/
2149
- def empty [ T ] : Observable [T ] = {
2150
- toScalaObservable(rx.Observable .empty[T ]())
2188
+ def empty : Observable [Nothing ] = {
2189
+ toScalaObservable(rx.Observable .empty[Nothing ]())
2151
2190
}
2152
2191
2153
2192
/**
@@ -2159,16 +2198,15 @@ object Observable {
2159
2198
*
2160
2199
* @param scheduler the scheduler to call the
2161
2200
[[rx.lang.scala.Observer#onCompleted onCompleted ]] method
2162
- * @param T the type of the items (ostensibly) emitted by the Observable
2163
2201
* @return an Observable that returns no data to the [[rx.lang.scala.Observer ]] and
2164
2202
* immediately invokes the [[rx.lang.scala.Observer ]]r's
2165
2203
* [[rx.lang.scala.Observer#onCompleted onCompleted ]] method with the
2166
2204
* specified scheduler
2167
2205
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#empty-error-and-never">RxJava Wiki: empty()</a>
2168
2206
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229066.aspx">MSDN: Observable.Empty Method (IScheduler)</a>
2169
2207
*/
2170
- def empty [ T ] (scheduler : Scheduler ): Observable [T ] = {
2171
- toScalaObservable(rx.Observable .empty[T ](scalaSchedulerToJavaScheduler(scheduler)))
2208
+ def empty (scheduler : Scheduler ): Observable [Nothing ] = {
2209
+ toScalaObservable(rx.Observable .empty[Nothing ](scalaSchedulerToJavaScheduler(scheduler)))
2172
2210
}
2173
2211
2174
2212
/**
0 commit comments