@Test public void fallbackBackpressured() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Single.<Integer>empty() .switchIfEmpty(Single.just(2)) .subscribe(ts); ts .assertEmpty() .request(1) .assertResult(2); }
@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);  }