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