use of io.reactivex.disposables.Disposable in project RxAndroid by ReactiveX.
the class MainThreadDisposableTest method unsubscribeTwiceDoesNotRunTwice.
@Test
public void unsubscribeTwiceDoesNotRunTwice() {
final AtomicInteger called = new AtomicInteger(0);
Disposable disposable = new MainThreadDisposable() {
@Override
protected void onDispose() {
called.incrementAndGet();
}
};
disposable.dispose();
disposable.dispose();
disposable.dispose();
assertEquals(1, called.get());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class CompletableFromRunnable method subscribeActual.
@Override
protected void subscribeActual(CompletableObserver s) {
Disposable d = Disposables.empty();
s.onSubscribe(d);
try {
runnable.run();
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
if (!d.isDisposed()) {
s.onError(e);
}
return;
}
if (!d.isDisposed()) {
s.onComplete();
}
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class CompletableSubscribeOn method subscribeActual.
@Override
protected void subscribeActual(final CompletableObserver s) {
final SubscribeOnObserver parent = new SubscribeOnObserver(s, source);
s.onSubscribe(parent);
Disposable f = scheduler.scheduleDirect(parent);
parent.task.replace(f);
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class BlockingBaseObserver method dispose.
@Override
public final void dispose() {
cancelled = true;
Disposable d = this.d;
if (d != null) {
d.dispose();
}
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class BlockingMultiObserver method dispose.
void dispose() {
cancelled = true;
Disposable d = this.d;
if (d != null) {
d.dispose();
}
}
Aggregations