BlockingObservable { public Iterable<T> toIterable() { return new Iterable<T>() { @Override public Iterator<T> iterator() { return getIterator(); } }; } private  BlockingObservable(Observable<? extends T> o); static BlockingObservable<T> from(final Observable<? extends T> o); void forEach(final Action1<? super T> onNext); Iterator<T> getIterator(); T first(); T first(Func1<? super T, Boolean> predicate); T firstOrDefault(T defaultValue); T firstOrDefault(T defaultValue, Func1<? super T, Boolean> predicate); T last(); T last(final Func1<? super T, Boolean> predicate); T lastOrDefault(T defaultValue); T lastOrDefault(T defaultValue, Func1<? super T, Boolean> predicate); Iterable<T> mostRecent(T initialValue); Iterable<T> next(); Iterable<T> latest(); T single(); T single(Func1<? super T, Boolean> predicate); T singleOrDefault(T defaultValue); T singleOrDefault(T defaultValue, Func1<? super T, Boolean> predicate); Future<T> toFuture(); Iterable<T> toIterable();  }
@Test public void testToIterable() { BlockingObservable<String> obs = BlockingObservable.from(Observable.just("one", "two", "three")); Iterator<String> it = obs.toIterable().iterator(); assertEquals(true, it.hasNext()); assertEquals("one", it.next()); assertEquals(true, it.hasNext()); assertEquals("two", it.next()); assertEquals(true, it.hasNext()); assertEquals("three", it.next()); assertEquals(false, it.hasNext()); }
@Test public void testToIterable() { BlockingObservable<String> obs = BlockingObservable.from(Observable.from("one", "two", "three")); Iterator<String> it = obs.toIterable().iterator(); assertEquals(true, it.hasNext()); assertEquals("one", it.next()); assertEquals(true, it.hasNext()); assertEquals("two", it.next()); assertEquals(true, it.hasNext()); assertEquals("three", it.next()); assertEquals(false, it.hasNext()); }