use of io.reactivex.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);
Disposable d = scheduler.schedulePeriodicallyDirect(is, initialDelay, period, unit);
is.setResource(d);
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class DefaultObserver method cancel.
/**
* Cancels the upstream's disposable.
*/
protected final void cancel() {
Disposable s = this.s;
this.s = DisposableHelper.DISPOSED;
s.dispose();
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class CompletableTest method subscribeReportsUnsubscribedOnError.
@Test
public void subscribeReportsUnsubscribedOnError() {
PublishSubject<String> stringSubject = PublishSubject.create();
Completable completable = stringSubject.ignoreElements();
Disposable completableSubscription = completable.subscribe();
stringSubject.onError(new TestException());
assertTrue("Not unsubscribed?", completableSubscription.isDisposed());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class CompletableTest method subscribeActionReportsUnsubscribed.
@Test
public void subscribeActionReportsUnsubscribed() {
PublishSubject<String> stringSubject = PublishSubject.create();
Completable completable = stringSubject.ignoreElements();
Disposable completableSubscription = completable.subscribe(new Action() {
@Override
public void run() {
}
});
stringSubject.onComplete();
assertTrue("Not unsubscribed?", completableSubscription.isDisposed());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class CompletableTest method subscribe.
@Test(timeout = 1000)
public void subscribe() throws InterruptedException {
final AtomicBoolean complete = new AtomicBoolean();
Completable c = normal.completable.delay(100, TimeUnit.MILLISECONDS).doOnComplete(new Action() {
@Override
public void run() {
complete.set(true);
}
});
Disposable d = c.subscribe();
assertFalse(d.isDisposed());
Thread.sleep(150);
Assert.assertTrue("Not completed", complete.get());
assertTrue(d.isDisposed());
}
Aggregations