Top Description Inners Fields Constructors Methods
rx.subjects

public final Class ReplaySubject<T>

extends Subject<T, T>
Class Inheritance
Type Parameters
<T>
the type of items observed and emitted by the Subject
Imports
java.lang.reflect.Array, java.util.*, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.*, rx.*, .Observer, rx.exceptions.Exceptions, rx.internal.operators.BackpressureUtils, rx.plugins.RxJavaHooks, rx.schedulers.Schedulers

Subject that buffers all items it observes and replays them to any Observer that subscribes.

Example usage:

 ReplaySubject<Object> subject = ReplaySubject.create();
 subject.onNext("one");
 subject.onNext("two");
 subject.onNext("three");
 subject.onCompleted();

 // both of the following will get the onNext/onCompleted calls from above
 subject.subscribe(observer1);
 subject.subscribe(observer2);

  

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
ReplaySubject.ReplayBuffer<
the value type
T
>

The base interface for buffering signals to be replayed to individual Subscribers.

pack-priv static class
ReplaySubject.ReplayProducer<
the value type
T
>

A producer and subscription implementation that tracks the current replay position of a particular subscriber.

pack-priv static class
pack-priv static class
pack-priv static class
ReplaySubject.ReplayState<
the value type
T
>

Holds onto the array of Subscriber-wrapping ReplayProducers and the buffer that holds values to be replayed; it manages subscription and signal dispatching.

pack-priv static class
ReplaySubject.ReplayUnboundedBuffer<
the value type
T
>

An unbounded ReplayBuffer implementation that uses linked-arrays to avoid copy-on-grow situation with ArrayList.

Field Summary

Modifier and TypeField and Description
private static final Object[]
EMPTY_ARRAY

An empty array to trigger getValues() to return a new array.

pack-priv final ReplaySubject.ReplayState<T>
state

The state storing the history and the references.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
create
()

Creates an unbounded replay subject.

public static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
create
(int
the initial buffer capacity
capacity
)

Creates an unbounded replay subject with the specified initial buffer capacity.

pack-priv static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
createUnbounded
()

Creates an unbounded replay subject with the bounded-implementation for testing purposes.

pack-priv static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
createUnboundedTime
()

Creates an unbounded replay subject with the time-bounded-implementation for testing purposes.

public static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
createWithSize
(int
the maximum number of buffered items
size
)

Creates a size-bounded replay subject.

public static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
createWithTime
(long
the maximum age of the contained items
time
,
TimeUnit
the time unit of time
unit
,
final Scheduler
the Scheduler that provides the current time
scheduler
)

Creates a time-bounded replay subject.

public static <
the type of items observed and emitted by the Subject
T
>
ReplaySubject<T>

Returns:

the created subject
createWithTimeAndSize
(long
the maximum age of the contained items
time
,
TimeUnit
the time unit of time
unit
,
int
the maximum number of buffered items
size
,
final Scheduler
the Scheduler that provides the current time
scheduler
)

Creates a time- and size-bounded replay subject.

public Throwable

Returns:

the Throwable that terminated the Subject or null if the subject hasn't terminated yet or it terminated normally.
getThrowable
()

Returns the Throwable that terminated the Subject.

public T

Returns:

the latest value available
getValue
()

public T[]

Returns:

the array a if it had enough capacity or a new array containing the available values
getValues
(T[]
the array to fill in
a
)

Returns a snapshot of the currently buffered non-terminal events into the provided a array or creates a new array if it has not enough capacity.

public Object[]

Returns:

a snapshot of the currently buffered non-terminal events.
getValues
()

Returns a snapshot of the currently buffered non-terminal events.

public boolean

Returns:

true if the Subject holds at least one non-terminal event available for replay
hasAnyValue
()

public boolean

Returns:

true if the subject completed normally via onCompleted
hasCompleted
()

Check if the Subject has terminated normally.

public boolean
hasObservers()

Implements abstract rx.subjects.Subject.hasObservers.

Indicates whether the Subject has Observers subscribed to it.
public boolean

Returns:

true if the subject has received a throwable through onError.
hasThrowable
()

Check if the Subject has terminated with an exception.

public boolean

Returns:

true if the Subject holds at least one non-terminal event available for replay
hasValue
()

public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(final Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
public int

Returns:

the number of items available
size
()

Returns the current number of items (non-terminal events) available for replay.

pack-priv int

Returns:

Returns the number of subscribers.
subscriberCount
()

Inherited from rx.subjects.Subject:
toSerialized