@@ -1243,6 +1243,25 @@ class Observable[+T](val asJava: rx.Observable[_ <: T])
1243
1243
// TODO naming: follow C# (switch) or Java (switchOnNext)?
1244
1244
// public static <T> Observable<T> switchOnNext(Observable<? extends Observable<? extends T>> sequenceOfSequences)
1245
1245
1246
+ /**
1247
+ * Flattens two Observables into one Observable, without any transformation.
1248
+ * <p>
1249
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/merge.png">
1250
+ * <p>
1251
+ * You can combine items emitted by two Observables so that they act like a single
1252
+ * Observable by using the {@code merge} method.
1253
+ *
1254
+ * @param that
1255
+ * an Observable to be merged
1256
+ * @return an Observable that emits items from {@code this} and {@code that} until
1257
+ * {@code this} or {@code that} emits {@code onError} or {@code onComplete}.
1258
+ */
1259
+ def merge [U >: T ](that : Observable [U ]): Observable [U ] = {
1260
+ val thisJava : rx.Observable [_ <: U ] = this .asJava
1261
+ val thatJava : rx.Observable [_ <: U ] = that.asJava
1262
+ new Observable [U ](rx.Observable .merge(thisJava, thatJava))
1263
+ }
1264
+
1246
1265
/**
1247
1266
* Converts an Observable into a {@link BlockingObservable} (an Observable with blocking
1248
1267
* operators).
@@ -1410,7 +1429,7 @@ object Observable {
1410
1429
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge</a>
1411
1430
*/
1412
1431
// public static <T> Observable<T> merge(List<? extends Observable<? extends T>> source)
1413
- // TODO decide if instance method mergeWith (?)
1432
+ // TODO do we need this or is the binary instance method merge sufficient?
1414
1433
1415
1434
/**
1416
1435
* Flattens a sequence of Observables emitted by an Observable into one Observable, without any
@@ -1428,7 +1447,6 @@ object Observable {
1428
1447
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
1429
1448
*/
1430
1449
// public static <T> Observable<T> merge(Observable<? extends Observable<? extends T>> source)
1431
- // TODO decide if instance method mergeWith (?)
1432
1450
1433
1451
/**
1434
1452
* Flattens a series of Observables into one Observable, without any transformation.
0 commit comments