Search in sources :

Example 16 with Disposable

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

Example 17 with Disposable

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

Example 18 with Disposable

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

Example 19 with Disposable

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

Example 20 with Disposable

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());
}
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