File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1649,6 +1649,17 @@ public void onNext(T t) {
16491649 public final Single <T > subscribeOn (Scheduler scheduler ) {
16501650 return nest ().lift (new OperatorSubscribeOn <T >(scheduler ));
16511651 }
1652+
1653+ /**
1654+ * Converts this Single into an {@link Observable}.
1655+ * <p>
1656+ * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.toObservable.png" alt="">
1657+ *
1658+ * @return an {@link Observable} that emits a single item T.
1659+ */
1660+ public final Observable <T > toObservable () {
1661+ return asObservable (this );
1662+ }
16521663
16531664 /**
16541665 * Returns a Single that mirrors the source Single but applies a timeout policy for its emitted item. If it
Original file line number Diff line number Diff line change @@ -452,4 +452,13 @@ public void onStart() {
452452
453453 ts .assertValue ("hello" );
454454 }
455+
456+ @ Test
457+ public void testToObservable () {
458+ Observable <String > a = Single .just ("a" ).toObservable ();
459+ TestSubscriber <String > ts = TestSubscriber .create ();
460+ a .subscribe (ts );
461+ ts .assertValue ("a" );
462+ ts .assertCompleted ();
463+ }
455464}
You can’t perform that action at this time.
0 commit comments