use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class FlowableIntervalRange method subscribeActual.
@Override
public void subscribeActual(Subscriber<? super Long> s) {
IntervalRangeSubscriber is = new IntervalRangeSubscriber(s, start, end);
s.onSubscribe(is);
Scheduler sch = scheduler;
if (sch instanceof TrampolineScheduler) {
Worker worker = sch.createWorker();
is.setResource(worker);
worker.schedulePeriodically(is, initialDelay, period, unit);
} else {
Disposable d = sch.schedulePeriodicallyDirect(is, initialDelay, period, unit);
is.setResource(d);
}
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class BlockingFirstObserverTest method firstValueOnly.
@Test
public void firstValueOnly() {
BlockingFirstObserver<Integer> bf = new BlockingFirstObserver<>();
Disposable d = Disposable.empty();
bf.onSubscribe(d);
bf.onNext(1);
assertTrue(d.isDisposed());
assertEquals(1, bf.value.intValue());
assertEquals(0, bf.getCount());
bf.onNext(2);
assertEquals(1, bf.value.intValue());
assertEquals(0, bf.getCount());
bf.onError(new TestException());
assertEquals(1, bf.value.intValue());
assertNull(bf.error);
assertEquals(0, bf.getCount());
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class FutureMultiObserverTest method cancelBeforeOnSubscribe.
@Test
public void cancelBeforeOnSubscribe() {
FutureMultiObserver<Integer> f = new FutureMultiObserver<>();
assertTrue(f.cancel(true));
Disposable d = Disposable.empty();
f.onSubscribe(d);
assertTrue(d.isDisposed());
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method fusedError.
@Test
public void fusedError() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.ANY);
TakeLast source = new TakeLast(to);
Disposable d = Disposable.empty();
source.onSubscribe(d);
source.onNext(1);
source.onError(new TestException());
source.onError(new TestException("second"));
source.onComplete();
to.assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class, "second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method normal.
@Test
public void normal() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = new TestObserver<>();
TakeFirst source = new TakeFirst(to);
source.onSubscribe(Disposable.empty());
Disposable d = Disposable.empty();
source.onSubscribe(d);
assertTrue(d.isDisposed());
source.onNext(1);
to.assertResult(1);
TestHelper.assertError(errors, 0, ProtocolViolationException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations