@@ -731,7 +731,7 @@ public static <T> Observable<T> error(Throwable exception, Scheduler scheduler)
731
731
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
732
732
*/
733
733
public static <T > Observable <T > from (Iterable <? extends T > iterable ) {
734
- return create ( OperationToObservableIterable . toObservableIterable ( iterable ));
734
+ return from ( iterable , Schedulers . currentThread ( ));
735
735
}
736
736
737
737
/**
@@ -750,7 +750,7 @@ public static <T> Observable<T> from(Iterable<? extends T> iterable) {
750
750
* @see <a href="http://msdn.microsoft.com/en-us/library/hh212140.aspx">MSDN: Observable.ToObservable</a>
751
751
*/
752
752
public static <T > Observable <T > from (Iterable <? extends T > iterable , Scheduler scheduler ) {
753
- return from ( iterable ). observeOn ( scheduler );
753
+ return create ( OperationToObservableIterable . toObservableIterable ( iterable , scheduler ) );
754
754
}
755
755
756
756
/**
@@ -763,14 +763,35 @@ public static <T> Observable<T> from(Iterable<? extends T> iterable, Scheduler s
763
763
* {@link Subscription} is returned, it is not possible to unsubscribe from
764
764
* the sequence before it completes.
765
765
*
766
- * @param items the source sequence
766
+ * @param items the source array
767
767
* @param <T> the type of items in the Array and the type of items to be
768
768
* emitted by the resulting Observable
769
769
* @return an Observable that emits each item in the source Array
770
770
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
771
771
*/
772
772
public static <T > Observable <T > from (T [] items ) {
773
- return create (OperationToObservableIterable .toObservableIterable (Arrays .asList (items )));
773
+ return from (Arrays .asList (items ));
774
+ }
775
+
776
+ /**
777
+ * Converts an Array into an Observable.
778
+ * <p>
779
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/from.png">
780
+ * <p>
781
+ * Note: the entire array is immediately emitted each time an
782
+ * {@link Observer} subscribes. Since this occurs before the
783
+ * {@link Subscription} is returned, it is not possible to unsubscribe from
784
+ * the sequence before it completes.
785
+ *
786
+ * @param items the source array
787
+ * @param scheduler the scheduler to emit the items of the array
788
+ * @param <T> the type of items in the Array and the type of items to be
789
+ * emitted by the resulting Observable
790
+ * @return an Observable that emits each item in the source Array
791
+ * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
792
+ */
793
+ public static <T > Observable <T > from (T [] items , Scheduler scheduler ) {
794
+ return from (Arrays .asList (items ), scheduler );
774
795
}
775
796
776
797
/**
@@ -827,7 +848,7 @@ public static <T> Observable<T> from(T t1, T t2) {
827
848
* subscribes. Since this occurs before the {@link Subscription} is
828
849
* returned, it is not possible to unsubscribe from the sequence before it
829
850
* completes.
830
- *
851
+ *
831
852
* @param t1 first item
832
853
* @param t2 second item
833
854
* @param t3 third item
@@ -1012,11 +1033,6 @@ public static <T> Observable<T> from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T
1012
1033
* <p>
1013
1034
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/from.png">
1014
1035
* <p>
1015
- * Note: the items will be immediately emitted each time an {@link Observer}
1016
- * subscribes. Since this occurs before the {@link Subscription} is
1017
- * returned, it is not possible to unsubscribe from the sequence before it
1018
- * completes.
1019
- *
1020
1036
* @param t1 first item
1021
1037
* @param t2 second item
1022
1038
* @param t3 third item
@@ -1044,11 +1060,6 @@ public static <T> Observable<T> from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T
1044
1060
* <p>
1045
1061
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/range.png">
1046
1062
* <p>
1047
- * Note: the entire range is immediately emitted each time an
1048
- * {@link Observer} subscribes. Since this occurs before the
1049
- * {@link Subscription} is returned, it is not possible to unsubscribe from
1050
- * the sequence before it completes.
1051
- *
1052
1063
* @param start the value of the first Integer in the sequence
1053
1064
* @param count the number of sequential Integers to generate
1054
1065
* @return an Observable that emits a range of sequential Integers
@@ -1073,7 +1084,7 @@ public static Observable<Integer> range(int start, int count) {
1073
1084
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211896.aspx">Observable.Range Method (Int32, Int32, IScheduler)</a>
1074
1085
*/
1075
1086
public static Observable <Integer > range (int start , int count , Scheduler scheduler ) {
1076
- return range ( start , count ). observeOn ( scheduler );
1087
+ return from ( Range . createWithCount ( start , count ), scheduler );
1077
1088
}
1078
1089
1079
1090
/**
@@ -1120,10 +1131,7 @@ public static <T> Observable<T> defer(Func0<? extends Observable<? extends T>> o
1120
1131
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#just">RxJava Wiki: just()</a>
1121
1132
*/
1122
1133
public static <T > Observable <T > just (T value ) {
1123
- List <T > list = new ArrayList <T >();
1124
- list .add (value );
1125
-
1126
- return from (list );
1134
+ return from (Arrays .asList ((value )));
1127
1135
}
1128
1136
1129
1137
/**
@@ -1142,7 +1150,7 @@ public static <T> Observable<T> just(T value) {
1142
1150
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#just">RxJava Wiki: just()</a>
1143
1151
*/
1144
1152
public static <T > Observable <T > just (T value , Scheduler scheduler ) {
1145
- return just ( value ). observeOn ( scheduler );
1153
+ return from ( Arrays . asList (( value )), scheduler );
1146
1154
}
1147
1155
1148
1156
/**
0 commit comments