File tree 2 files changed +20
-0
lines changed
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) {
1649
1649
public final Single <T > subscribeOn (Scheduler scheduler ) {
1650
1650
return nest ().lift (new OperatorSubscribeOn <T >(scheduler ));
1651
1651
}
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
+ }
1652
1663
1653
1664
/**
1654
1665
* 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() {
452
452
453
453
ts .assertValue ("hello" );
454
454
}
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
+ }
455
464
}
You can’t perform that action at this time.
0 commit comments