public final class

UnicastProcessor

extends FlowableProcessor<T>
java.lang.Object
   ↳ io.reactivex.Flowable<T>
     ↳ io.reactivex.processors.FlowableProcessor<T>
       ↳ io.reactivex.processors.UnicastProcessor<T>

Class Overview

Processor that allows only a single Subscriber to subscribe to it during its lifetime.

This processor buffers notifications and replays them to the Subscriber as requested.

This processor holds an unbounded internal buffer.

If more than one Subscriber attempts to subscribe to this Processor, they will receive an IllegalStateException if this Processor hasn't terminated yet, or the Subscribers receive the terminal event (error or completion) if this Processor has terminated.

Summary

Public Methods
static <T> UnicastProcessor<T> create(int capacityHint, Runnable onCancelled)
Creates an UnicastProcessor with the given internal buffer capacity hint and a callback for the case when the single Subscriber cancels its subscription.
static <T> UnicastProcessor<T> create(int capacityHint)
Creates an UnicastProcessor with the given internal buffer capacity hint.
static <T> UnicastProcessor<T> create(boolean delayError)
Creates an UnicastProcessor with default internal buffer capacity hint and delay error flag.
static <T> UnicastProcessor<T> create(int capacityHint, Runnable onCancelled, boolean delayError)
Creates an UnicastProcessor with the given internal buffer capacity hint, delay error flag and a callback for the case when the single Subscriber cancels its subscription.
static <T> UnicastProcessor<T> create()
Creates an UnicastSubject with an internal buffer capacity hint 16.
Throwable getThrowable()
Returns the error that caused the Subject to terminate or null if the Subject hasn't terminated yet.
boolean hasComplete()
Returns true if the subject has reached a terminal state through a complete event.
boolean hasSubscribers()
Returns true if the subject has subscribers.
boolean hasThrowable()
Returns true if the subject has reached a terminal state through an error event.
void onComplete()
void onError(Throwable t)
void onNext(T t)
void onSubscribe(Subscription s)
Protected Methods
void subscribeActual(Subscriber<? super T> s)
Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic.
[Expand]
Inherited Methods
From class io.reactivex.processors.FlowableProcessor
From class io.reactivex.Flowable
From class java.lang.Object
From interface io.reactivex.FlowableSubscriber
From interface org.reactivestreams.Publisher
From interface org.reactivestreams.Subscriber

Public Methods

public static UnicastProcessor<T> create (int capacityHint, Runnable onCancelled)

Creates an UnicastProcessor with the given internal buffer capacity hint and a callback for the case when the single Subscriber cancels its subscription.

The callback, if not null, is called exactly once and non-overlapped with any active replay.

Parameters
capacityHint the hint to size the internal unbounded buffer
onCancelled the non null callback
Returns
  • an UnicastProcessor instance

public static UnicastProcessor<T> create (int capacityHint)

Creates an UnicastProcessor with the given internal buffer capacity hint.

Parameters
capacityHint the hint to size the internal unbounded buffer
Returns
  • an UnicastProcessor instance

public static UnicastProcessor<T> create (boolean delayError)

Creates an UnicastProcessor with default internal buffer capacity hint and delay error flag.

Parameters
delayError deliver pending onNext events before onError
Returns
  • an UnicastProcessor instance

public static UnicastProcessor<T> create (int capacityHint, Runnable onCancelled, boolean delayError)

Creates an UnicastProcessor with the given internal buffer capacity hint, delay error flag and a callback for the case when the single Subscriber cancels its subscription.

The callback, if not null, is called exactly once and non-overlapped with any active replay.

Parameters
capacityHint the hint to size the internal unbounded buffer
onCancelled the non null callback
delayError deliver pending onNext events before onError
Returns
  • an UnicastProcessor instance

public static UnicastProcessor<T> create ()

Creates an UnicastSubject with an internal buffer capacity hint 16.

Returns
  • an UnicastSubject instance

public Throwable getThrowable ()

Returns the error that caused the Subject to terminate or null if the Subject hasn't terminated yet.

The method is thread-safe.

Returns
  • the error that caused the Subject to terminate or null if the Subject hasn't terminated yet

public boolean hasComplete ()

Returns true if the subject has reached a terminal state through a complete event.

The method is thread-safe.

Returns
  • true if the subject has reached a terminal state through a complete event

public boolean hasSubscribers ()

Returns true if the subject has subscribers.

The method is thread-safe.

Returns
  • true if the subject has subscribers

public boolean hasThrowable ()

Returns true if the subject has reached a terminal state through an error event.

The method is thread-safe.

Returns
  • true if the subject has reached a terminal state through an error event

public void onComplete ()

public void onError (Throwable t)

public void onNext (T t)

public void onSubscribe (Subscription s)

Protected Methods

protected void subscribeActual (Subscriber<? super T> s)

Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic.

There is no need to call any of the plugin hooks on the current Flowable instance or the Subscriber.

Parameters
s the incoming Subscriber, never null