@Test public void cancelOther() { SubmissionPublisher<Integer> sp = new SubmissionPublisher<>(Runnable::run, 128); TestSubscriber<Integer> ts = new TestSubscriber<>(Long.MAX_VALUE); Single.<Integer>empty() .switchIfEmpty(Single.create(sp)) .subscribe(ts); assertTrue(sp.hasSubscribers()); ts.assertEmpty(); ts.cancel(); assertFalse(sp.hasSubscribers()); }
@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);  }