Search in sources :

Example 1 with Disposable

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());
}
Also used : Disposable(io.reactivex.disposables.Disposable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Example 2 with Disposable

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();
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable)

Example 3 with Disposable

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);
}
Also used : Disposable(io.reactivex.disposables.Disposable)

Example 4 with Disposable

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();
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable)

Example 5 with Disposable

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();
    }
}
Also used : Disposable(io.reactivex.disposables.Disposable)

Aggregations

Disposable (io.reactivex.disposables.Disposable)199 Test (org.junit.Test)95 Logger (chat.rocket.android.helper.Logger)19 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)18 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)17 Worker (io.reactivex.Scheduler.Worker)15 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)13 CountingRunnable (io.reactivex.android.testutil.CountingRunnable)10 EmptyDisposable (io.reactivex.internal.disposables.EmptyDisposable)10 TestSubscriber (io.reactivex.subscribers.TestSubscriber)10 Optional (com.fernandocejas.arrow.optional.Optional)9 Single (io.reactivex.Single)9 Nullable (android.support.annotation.Nullable)8 Function (io.reactivex.functions.Function)8 Bundle (android.os.Bundle)7 Pair (android.support.v4.util.Pair)7 ANError (com.androidnetworking.error.ANError)7 AnalyticsListener (com.androidnetworking.interfaces.AnalyticsListener)7 List (java.util.List)7 NonNull (android.support.annotation.NonNull)6