@@ -2266,6 +2266,36 @@ trait Observable[+T]
2266
2266
)
2267
2267
}
2268
2268
2269
+ /**
2270
+ * Returns an Observable that correlates two Observables when they overlap in time and groups the results.
2271
+ *
2272
+ * <img width="640" height="380" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/groupJoin.png">
2273
+ *
2274
+ * @param other the other Observable to correlate items from the source Observable with
2275
+ * @param leftDuration a function that returns an Observable whose emissions indicate the duration of the values of
2276
+ * the source Observable
2277
+ * @param rightDuration a function that returns an Observable whose emissions indicate the duration of the values of
2278
+ * the `other` Observable
2279
+ * @param resultSelector a function that takes an item emitted by each Observable and returns the value to be emitted
2280
+ * by the resulting Observable
2281
+ * @return an Observable that emits items based on combining those items emitted by the source Observables
2282
+ * whose durations overlap
2283
+ */
2284
+ def groupJoin [S , R ](other : Observable [S ], leftDuration : T => Observable [Any ], rightDuration : S => Observable [Any ], resultSelector : (T , Observable [S ]) => R ): Observable [R ] = {
2285
+ val outer : rx.Observable [_ <: T ] = this .asJavaObservable
2286
+ val inner : rx.Observable [_ <: S ] = other.asJavaObservable
2287
+ val left : Func1 [_ >: T , _ <: rx.Observable [_ <: Any ]] = (t : T ) => leftDuration(t).asJavaObservable
2288
+ val right : Func1 [_ >: S , _ <: rx.Observable [_ <: Any ]] = (s : S ) => rightDuration(s).asJavaObservable
2289
+ val f : Func2 [_ >: T , _ >: rx.Observable [S ], _ <: R ] = (t : T , o : rx.Observable [S ]) => resultSelector(t, toScalaObservable[S ](o))
2290
+ toScalaObservable[R ](
2291
+ outer.asInstanceOf [rx.Observable [T ]].groupJoin[S , Any , Any , R ](
2292
+ inner.asInstanceOf [rx.Observable [S ]],
2293
+ left.asInstanceOf [Func1 [T , rx.Observable [Any ]]],
2294
+ right.asInstanceOf [Func1 [S , rx.Observable [Any ]]],
2295
+ f)
2296
+ )
2297
+ }
2298
+
2269
2299
/**
2270
2300
* Returns a new Observable by applying a function that you supply to each item emitted by the source
2271
2301
* Observable that returns an Observable, and then emitting the items emitted by the most recently emitted
0 commit comments