@@ -732,7 +732,7 @@ public static <T> Observable<T> error(Throwable exception, Scheduler scheduler)
732732 * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
733733 */
734734 public static <T > Observable <T > from (Iterable <? extends T > iterable ) {
735- return create ( OperationToObservableIterable . toObservableIterable ( iterable ));
735+ return from ( iterable , Schedulers . currentThread ( ));
736736 }
737737
738738 /**
@@ -751,7 +751,7 @@ public static <T> Observable<T> from(Iterable<? extends T> iterable) {
751751 * @see <a href="http://msdn.microsoft.com/en-us/library/hh212140.aspx">MSDN: Observable.ToObservable</a>
752752 */
753753 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 ) );
755755 }
756756
757757 /**
@@ -764,14 +764,35 @@ public static <T> Observable<T> from(Iterable<? extends T> iterable, Scheduler s
764764 * {@link Subscription} is returned, it is not possible to unsubscribe from
765765 * the sequence before it completes.
766766 *
767- * @param items the source sequence
767+ * @param items the source array
768768 * @param <T> the type of items in the Array and the type of items to be
769769 * emitted by the resulting Observable
770770 * @return an Observable that emits each item in the source Array
771771 * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
772772 */
773773 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 );
775796 }
776797
777798 /**
@@ -828,7 +849,7 @@ public static <T> Observable<T> from(T t1, T t2) {
828849 * subscribes. Since this occurs before the {@link Subscription} is
829850 * returned, it is not possible to unsubscribe from the sequence before it
830851 * completes.
831- *
852+ *
832853 * @param t1 first item
833854 * @param t2 second item
834855 * @param t3 third item
@@ -1074,7 +1095,7 @@ public static Observable<Integer> range(int start, int count) {
10741095 * @see <a href="http://msdn.microsoft.com/en-us/library/hh211896.aspx">Observable.Range Method (Int32, Int32, IScheduler)</a>
10751096 */
10761097 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 );
10781099 }
10791100
10801101 /**
@@ -1121,10 +1142,7 @@ public static <T> Observable<T> defer(Func0<? extends Observable<? extends T>> o
11211142 * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#just">RxJava Wiki: just()</a>
11221143 */
11231144 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 )));
11281146 }
11291147
11301148 /**
@@ -1143,7 +1161,7 @@ public static <T> Observable<T> just(T value) {
11431161 * @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#just">RxJava Wiki: just()</a>
11441162 */
11451163 public static <T > Observable <T > just (T value , Scheduler scheduler ) {
1146- return just ( value ). observeOn ( scheduler );
1164+ return from ( Arrays . asList (( value )), scheduler );
11471165 }
11481166
11491167 /**
0 commit comments