@Test public void testFromCollection() throws Exception { List<Integer> ints = Arrays.asList(1, 2, 3, 4, 5); Observable<Integer> obs = Observable.from(ints); validateObservable(obs, ints, 5, 1, 0); }
@NonNull public static <T> Observable<T> from(@NonNull final Collection<T> collection) { return create(new Function<Observer<T>, Subscription>() { @NonNull @Override public Subscription apply(@NonNull final Observer<T> observer) { for (final T value : collection) { observer.onNext(value); } observer.onCompleted(); return Subscription.empty(); } }); }
Observable { @NonNull public static <T> Observable<T> from(@NonNull final Collection<T> collection) { return create(new Function<Observer<T>, Subscription>() { @NonNull @Override public Subscription apply(@NonNull final Observer<T> observer) { for (final T value : collection) { observer.onNext(value); } observer.onCompleted(); return Subscription.empty(); } }); } }
Observable { @NonNull public static <T> Observable<T> from(@NonNull final Collection<T> collection) { return create(new Function<Observer<T>, Subscription>() { @NonNull @Override public Subscription apply(@NonNull final Observer<T> observer) { for (final T value : collection) { observer.onNext(value); } observer.onCompleted(); return Subscription.empty(); } }); } protected  Observable(); protected  Observable(@Nullable Function<Observer<T>, Subscription> onSubscribe); }
Observable { @NonNull public static <T> Observable<T> from(@NonNull final Collection<T> collection) { return create(new Function<Observer<T>, Subscription>() { @NonNull @Override public Subscription apply(@NonNull final Observer<T> observer) { for (final T value : collection) { observer.onNext(value); } observer.onCompleted(); return Subscription.empty(); } }); } protected  Observable(); protected  Observable(@Nullable Function<Observer<T>, Subscription> onSubscribe); @NonNull static Observable<T> create(@NonNull Function<Observer<T>, Subscription> func); @NonNull static Observable<T> just(@NonNull final T value); @NonNull static Observable<T> empty(); @NonNull static Observable<T> never(); @NonNull static Observable<T> error(@NonNull final Exception e); @NonNull static Observable<T> from(@NonNull final Collection<T> collection); @NonNull Subscription subscribe(@NonNull Observer<T> observer); @NonNull Observable<R> flatMap(@NonNull final Function<T, Observable<R>> func); @NonNull Observable<R> map(@NonNull final Function<T, R> func); @NonNull Observable<T> filter(@NonNull final Predicate<T> pred); @NonNull Observable<T> distinctUntilChanged(); @NonNull Observable<T> defaultIfEmpty(@NonNull final T defaultValue); @NonNull Observable<T> observeOn(@NonNull final Scheduler scheduler); @NonNull Observable<T> subscribeOn(@NonNull final Scheduler scheduler); @NonNull static Observable<T> merge(@NonNull final Observable<T> lh, @NonNull final Observable<T> rh); @NonNull static Observable<T> merge(@NonNull Collection<Observable<T>> observables); @NonNull static Observable<T> concat(@NonNull final Observable<T> lh, @NonNull final Observable<T> rh); @NonNull static Observable<T> defer(@NonNull final Supplier<Observable<T>> func); @NonNull static Observable<R> zip(@NonNull final Observable<T> lh, @NonNull final Observable<T> rh, @NonNull final BiFunction<T, T, R> func); }
Observable { @NonNull public static <T> Observable<T> from(@NonNull final Collection<T> collection) { return create(new Function<Observer<T>, Subscription>() { @NonNull @Override public Subscription apply(@NonNull final Observer<T> observer) { for (final T value : collection) { observer.onNext(value); } observer.onCompleted(); return Subscription.empty(); } }); } protected  Observable(); protected  Observable(@Nullable Function<Observer<T>, Subscription> onSubscribe); @NonNull static Observable<T> create(@NonNull Function<Observer<T>, Subscription> func); @NonNull static Observable<T> just(@NonNull final T value); @NonNull static Observable<T> empty(); @NonNull static Observable<T> never(); @NonNull static Observable<T> error(@NonNull final Exception e); @NonNull static Observable<T> from(@NonNull final Collection<T> collection); @NonNull Subscription subscribe(@NonNull Observer<T> observer); @NonNull Observable<R> flatMap(@NonNull final Function<T, Observable<R>> func); @NonNull Observable<R> map(@NonNull final Function<T, R> func); @NonNull Observable<T> filter(@NonNull final Predicate<T> pred); @NonNull Observable<T> distinctUntilChanged(); @NonNull Observable<T> defaultIfEmpty(@NonNull final T defaultValue); @NonNull Observable<T> observeOn(@NonNull final Scheduler scheduler); @NonNull Observable<T> subscribeOn(@NonNull final Scheduler scheduler); @NonNull static Observable<T> merge(@NonNull final Observable<T> lh, @NonNull final Observable<T> rh); @NonNull static Observable<T> merge(@NonNull Collection<Observable<T>> observables); @NonNull static Observable<T> concat(@NonNull final Observable<T> lh, @NonNull final Observable<T> rh); @NonNull static Observable<T> defer(@NonNull final Supplier<Observable<T>> func); @NonNull static Observable<R> zip(@NonNull final Observable<T> lh, @NonNull final Observable<T> rh, @NonNull final BiFunction<T, T, R> func);  }