@Test public void fusedAPICalls() { Flowable.fromIterable(Arrays.asList(1, 2, 3)) .subscribe(new FlowableSubscriber<Integer>() { @Override public void onSubscribe(Subscription s) { @SuppressWarnings("unchecked") QueueSubscription<Integer> qs = (QueueSubscription<Integer>)s; assertFalse(qs.isEmpty()); try { assertEquals(1, qs.poll().intValue()); } catch (Exception ex) { throw new AssertionError(ex); } assertFalse(qs.isEmpty()); qs.clear(); List<Throwable> errors = TestHelper.trackPluginErrors(); try { qs.request(-99); TestHelper.assertError(errors, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); } finally { RxJavaPlugins.reset(); } } @Override public void onNext(Integer t) { } @Override public void onError(Throwable t) { } @Override public void onComplete() { } }); }
public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } FlowableFromIterable(Iterable<? extends T> source); }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } FlowableFromIterable(Iterable<? extends T> source); @Override void subscribeActual(Subscriber<? super T> s); static void subscribe(Subscriber<? super T> s, Iterator<? extends T> it); }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } FlowableFromIterable(Iterable<? extends T> source); @Override void subscribeActual(Subscriber<? super T> s); static void subscribe(Subscriber<? super T> s, Iterator<? extends T> it);  }