Top Description Classes
[default module]

Package io.reactivex.subscribers


Default wrappers and implementations for Subscriber-based consumer classes and interfaces, including disposable and resource-tracking variants and the io.reactivex.subscribers.TestSubscriber that allows unit testing io.reactivex.Flowable-based flows.

Class Summary

Modifier and TypeClass and Description
public abstract class
DefaultSubscriber<
the value type

Example


Flowable.range(1, 5)
    .subscribe(new DefaultSubscriber<Integer>() {
        @Override public void onStart() {
            System.out.println("Start!");
            request(1);
        }
        @Override public void onNext(Integer t) {
            if (t == 3) {
                cancel();
            }
            System.out.println(t);
            request(1);
        }
        @Override public void onError(Throwable t) {
            t.printStackTrace();
        }
        @Override public void onComplete() {
            System.out.println("Done!");
        }
    });
T
>

Abstract base implementation of a Subscriber with support for requesting via request(long), cancelling via via cancel() (both synchronously) and calls onStart() when the subscription happens.

public abstract class
DisposableSubscriber<
the received value type.
T
>

An abstract Subscriber that allows asynchronous, external cancellation by implementing Disposable.

public abstract class
ResourceSubscriber<
the value type
T
>

An abstract Subscriber that allows asynchronous cancellation of its subscription and associated resources.

public class
SafeSubscriber<
the value type
T
>

Wraps another Subscriber and ensures all onXXX methods conform the protocol (except the requirement for serialized access).

public class
SerializedSubscriber<
the value type
T
>

Serializes access to the onNext, onError and onComplete methods of another Subscriber.

public class
TestSubscriber<
the value type
T
>

A subscriber that records events and allows making assertions about them.