@Test public void fallbackEmpty() { TestSubscriber<Integer> ts = new TestSubscriber<>(Long.MAX_VALUE); AtomicInteger count = new AtomicInteger(); Single.<Integer>empty() .switchIfEmpty(Single.<Integer>empty().onComplete(count::getAndIncrement)) .subscribe(ts); ts.assertResult(); }
@Override public void subscribe(Flow.Subscriber<? super T> subscriber) { source.subscribe(new SwitchIfEmptySubscriber<>(subscriber, fallback)); }
SingleSwitchIfEmpty extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { source.subscribe(new SwitchIfEmptySubscriber<>(subscriber, fallback)); } }
SingleSwitchIfEmpty extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { source.subscribe(new SwitchIfEmptySubscriber<>(subscriber, fallback)); } SingleSwitchIfEmpty(Single<T> source, Single<T> fallback); }
SingleSwitchIfEmpty extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { source.subscribe(new SwitchIfEmptySubscriber<>(subscriber, fallback)); } SingleSwitchIfEmpty(Single<T> source, Single<T> fallback); @Override void subscribe(Flow.Subscriber<? super T> subscriber); }
SingleSwitchIfEmpty extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { source.subscribe(new SwitchIfEmptySubscriber<>(subscriber, fallback)); } SingleSwitchIfEmpty(Single<T> source, Single<T> fallback); @Override void subscribe(Flow.Subscriber<? super T> subscriber);  }