@@ -732,7 +732,7 @@ public static <T> Observable<T> error(Throwable exception, Scheduler scheduler)
732
732
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
733
733
*/
734
734
public static <T > Observable <T > from (Iterable <? extends T > iterable ) {
735
- return create ( OperationToObservableIterable . toObservableIterable ( iterable ));
735
+ return from ( iterable , Schedulers . currentThread ( ));
736
736
}
737
737
738
738
/**
@@ -751,7 +751,7 @@ public static <T> Observable<T> from(Iterable<? extends T> iterable) {
751
751
* @see <a href="http://msdn.microsoft.com/en-us/library/hh212140.aspx">MSDN: Observable.ToObservable</a>
752
752
*/
753
753
public static <T > Observable <T > from (Iterable <? extends T > iterable , Scheduler scheduler ) {
754
- return from ( iterable ). observeOn ( scheduler );
754
+ return create ( OperationToObservableIterable . toObservableIterable ( iterable , scheduler ) );
755
755
}
756
756
757
757
/**
@@ -764,14 +764,35 @@ public static <T> Observable<T> from(Iterable<? extends T> iterable, Scheduler s
764
764
* {@link Subscription} is returned, it is not possible to unsubscribe from
765
765
* the sequence before it completes.
766
766
*
767
- * @param items the source sequence
767
+ * @param items the source array
768
768
* @param <T> the type of items in the Array and the type of items to be
769
769
* emitted by the resulting Observable
770
770
* @return an Observable that emits each item in the source Array
771
771
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
772
772
*/
773
773
public static <T > Observable <T > from (T [] items ) {
774
- return create (OperationToObservableIterable .toObservableIterable (Arrays .asList (items )));
774
+ return from (Arrays .asList (items ));
775
+ }
776
+
777
+ /**
778
+ * Converts an Array into an Observable.
779
+ * <p>
780
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/from.png">
781
+ * <p>
782
+ * Note: the entire array is immediately emitted each time an
783
+ * {@link Observer} subscribes. Since this occurs before the
784
+ * {@link Subscription} is returned, it is not possible to unsubscribe from
785
+ * the sequence before it completes.
786
+ *
787
+ * @param items the source array
788
+ * @param scheduler the scheduler to emit the items of the array
789
+ * @param <T> the type of items in the Array and the type of items to be
790
+ * emitted by the resulting Observable
791
+ * @return an Observable that emits each item in the source Array
792
+ * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
793
+ */
794
+ public static <T > Observable <T > from (T [] items , Scheduler scheduler ) {
795
+ return from (Arrays .asList (items ), scheduler );
775
796
}
776
797
777
798
/**
@@ -828,7 +849,7 @@ public static <T> Observable<T> from(T t1, T t2) {
828
849
* subscribes. Since this occurs before the {@link Subscription} is
829
850
* returned, it is not possible to unsubscribe from the sequence before it
830
851
* completes.
831
- *
852
+ *
832
853
* @param t1 first item
833
854
* @param t2 second item
834
855
* @param t3 third item
@@ -1074,7 +1095,7 @@ public static Observable<Integer> range(int start, int count) {
1074
1095
* @see <a href="http://msdn.microsoft.com/en-us/library/hh211896.aspx">Observable.Range Method (Int32, Int32, IScheduler)</a>
1075
1096
*/
1076
1097
public static Observable <Integer > range (int start , int count , Scheduler scheduler ) {
1077
- return range ( start , count ). observeOn ( scheduler );
1098
+ return from ( Range . createWithCount ( start , count ), scheduler );
1078
1099
}
1079
1100
1080
1101
/**
@@ -1121,10 +1142,7 @@ public static <T> Observable<T> defer(Func0<? extends Observable<? extends T>> o
1121
1142
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#just">RxJava Wiki: just()</a>
1122
1143
*/
1123
1144
public static <T > Observable <T > just (T value ) {
1124
- List <T > list = new ArrayList <T >();
1125
- list .add (value );
1126
-
1127
- return from (list );
1145
+ return from (Arrays .asList ((value )));
1128
1146
}
1129
1147
1130
1148
/**
@@ -1143,7 +1161,7 @@ public static <T> Observable<T> just(T value) {
1143
1161
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#just">RxJava Wiki: just()</a>
1144
1162
*/
1145
1163
public static <T > Observable <T > just (T value , Scheduler scheduler ) {
1146
- return just ( value ). observeOn ( scheduler );
1164
+ return from ( Arrays . asList (( value )), scheduler );
1147
1165
}
1148
1166
1149
1167
/**
0 commit comments