Skip to content

Commit 64c9f35

Browse files
Deprecating 'toObservable' duplications of 'from' methods
1 parent 0c9322b commit 64c9f35

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,11 +1996,31 @@ public static <T> Observable<T> toObservable(Iterable<T> iterable) {
19961996
* the type of of object that the future's returns and the type emitted by the resulting
19971997
* Observable
19981998
* @return an Observable that emits the item from the source Future
1999+
* @deprecated Replaced by {@link #from(Future)}
19992000
*/
20002001
public static <T> Observable<T> toObservable(Future<T> future) {
20012002
return create(OperationToObservableFuture.toObservableFuture(future));
20022003
}
20032004

2005+
/**
2006+
* Converts an Future to an Observable sequence.
2007+
*
2008+
* Any object that supports the {@link Future} interface can be converted into an Observable that emits
2009+
* the return value of the get() method in the object, by passing the object into the <code>toObservable</code> method.
2010+
* <p>
2011+
* This is blocking so the Subscription returned when calling {@link #subscribe(Observer)} does nothing.
2012+
*
2013+
* @param future
2014+
* the source {@link Future}
2015+
* @param <T>
2016+
* the type of of object that the future's returns and the type emitted by the resulting
2017+
* Observable
2018+
* @return an Observable that emits the item from the source Future
2019+
*/
2020+
public static <T> Observable<T> from(Future<T> future) {
2021+
return create(OperationToObservableFuture.toObservableFuture(future));
2022+
}
2023+
20042024
/**
20052025
* Converts an Future to an Observable sequence.
20062026
*
@@ -2020,11 +2040,36 @@ public static <T> Observable<T> toObservable(Future<T> future) {
20202040
* the type of of object that the future's returns and the type emitted by the resulting
20212041
* Observable
20222042
* @return an Observable that emits the item from the source Future
2043+
* @deprecated Replaced by {@link #from(Future, long, TimeUnit)}
20232044
*/
20242045
public static <T> Observable<T> toObservable(Future<T> future, long timeout, TimeUnit unit) {
20252046
return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit));
20262047
}
20272048

2049+
/**
2050+
* Converts an Future to an Observable sequence.
2051+
*
2052+
* Any object that supports the {@link Future} interface can be converted into an Observable that emits
2053+
* the return value of the get() method in the object, by passing the object into the <code>toObservable</code> method.
2054+
* The subscribe method on this synchronously so the Subscription returned doesn't nothing.
2055+
* <p>
2056+
* This is blocking so the Subscription returned when calling {@link #subscribe(Observer)} does nothing.
2057+
*
2058+
* @param future
2059+
* the source {@link Future}
2060+
* @param timeout
2061+
* the maximum time to wait
2062+
* @param unit
2063+
* the time unit of the time argument
2064+
* @param <T>
2065+
* the type of of object that the future's returns and the type emitted by the resulting
2066+
* Observable
2067+
* @return an Observable that emits the item from the source Future
2068+
*/
2069+
public static <T> Observable<T> from(Future<T> future, long timeout, TimeUnit unit) {
2070+
return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit));
2071+
}
2072+
20282073
/**
20292074
* Converts an Array sequence to an Observable sequence.
20302075
*
@@ -2039,6 +2084,7 @@ public static <T> Observable<T> toObservable(Future<T> future, long timeout, Tim
20392084
* the type of items in the Array, and the type of items emitted by the resulting
20402085
* Observable
20412086
* @return an Observable that emits each item in the source Array
2087+
* @deprecated Use {@link #from(Object...)}
20422088
*/
20432089
public static <T> Observable<T> toObservable(T... items) {
20442090
return toObservable(Arrays.asList(items));

0 commit comments

Comments
 (0)