Top Description Fields Constructors Methods
rx.subjects

public final Class TestSubject<T>

extends Subject<T, T>
Class Inheritance
Type Parameters
<T>
the type of item observed by and emitted by the subject
Imports
rx.Observer, .Scheduler, rx.functions.Action0, .Action1, rx.internal.operators.NotificationLite, rx.schedulers.TestScheduler, rx.subjects.SubjectSubscriptionManager.SubjectObserver, java.util.concurrent.TimeUnit

A variety of Subject that is useful for testing purposes. It operates on a TestScheduler and allows you to precisely time emissions and notifications to the Subject's subscribers using relative virtual time controlled by the TestScheduler.

Field Summary

Modifier and TypeField and Description
private final Scheduler.Worker
private final SubjectSubscriptionManager<T>

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static <
the value type
T
>
TestSubject<T>

Returns:

the new TestSubject
create
(TestScheduler
a TestScheduler on which to operate this Subject
scheduler
)

Creates and returns a new TestSubject.

public boolean
hasObservers()

Implements abstract rx.subjects.Subject.hasObservers.

Indicates whether the Subject has Observers subscribed to it.
pack-priv void
pack-priv void
pack-priv void
public void
onCompleted()

Implements rx.Observer.onCompleted.

Schedule a call to onCompleted on TestScheduler.
public void
onCompleted(long
the number of milliseconds in the future relative to "now()" at which to call onCompleted
delayTime
)

Schedule a call to onCompleted relative to "now()" +n milliseconds in the future.

public void
onError(final Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Schedule a call to onError on TestScheduler.
public void
onError(final Throwable
the Throwable to pass to the onError method
e
,
long
the number of milliseconds in the future relative to "now()" at which to call onError
delayTime
)

Schedule a call to onError relative to "now()" +n milliseconds in the future.

public void
onNext(T
the item emitted by the Observable
v
)

Implements rx.Observer.onNext.

Schedule a call to onNext on TestScheduler.
public void
onNext(final T
the item to emit
v
,
long
the number of milliseconds in the future relative to "now()" at which to call onNext
delayTime
)

Schedule a call to onNext relative to "now()" +n milliseconds in the future.

Inherited from rx.subjects.Subject:
toSerialized

Field Detail

innerSchedulerback to summary
private final Scheduler.Worker innerScheduler
stateback to summary
private final SubjectSubscriptionManager<T> state

Constructor Detail

TestSubjectback to summary
protected TestSubject(Observable.OnSubscribe<T> onSubscribe, SubjectSubscriptionManager<T> state, TestScheduler scheduler)

Method Detail

createback to summary
public static <T> TestSubject<T> create(TestScheduler scheduler)

Creates and returns a new TestSubject.

Parameters
<T>
the value type
scheduler:TestScheduler

a TestScheduler on which to operate this Subject

Returns:TestSubject<T>

the new TestSubject

hasObserversback to summary
public boolean hasObservers()

Implements abstract rx.subjects.Subject.hasObservers.

Doc from rx.subjects.Subject.hasObservers.

Indicates whether the Subject has Observers subscribed to it.

Returns:boolean

true if there is at least one Observer subscribed to this Subject, false otherwise

Annotations
@Override
internalOnCompletedback to summary
pack-priv void internalOnCompleted()
internalOnErrorback to summary
pack-priv void internalOnError(final Throwable e)
internalOnNextback to summary
pack-priv void internalOnNext(T v)
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Schedule a call to onCompleted on TestScheduler.

Annotations
@Override
onCompletedback to summary
public void onCompleted(long delayTime)

Schedule a call to onCompleted relative to "now()" +n milliseconds in the future.

Parameters
delayTime:long

the number of milliseconds in the future relative to "now()" at which to call onCompleted

onErrorback to summary
public void onError(final Throwable e)

Implements rx.Observer.onError.

Schedule a call to onError on TestScheduler.

Parameters
e:Throwable

Doc from rx.Observer.onError.

the exception encountered by the Observable

Annotations
@Override
onErrorback to summary
public void onError(final Throwable e, long delayTime)

Schedule a call to onError relative to "now()" +n milliseconds in the future.

Parameters
e:Throwable

the Throwable to pass to the onError method

delayTime:long

the number of milliseconds in the future relative to "now()" at which to call onError

onNextback to summary
public void onNext(T v)

Implements rx.Observer.onNext.

Schedule a call to onNext on TestScheduler.

Parameters
v:T

Doc from rx.Observer.onNext.

the item emitted by the Observable

Annotations
@Override
onNextback to summary
public void onNext(final T v, long delayTime)

Schedule a call to onNext relative to "now()" +n milliseconds in the future.

Parameters
v:T

the item to emit

delayTime:long

the number of milliseconds in the future relative to "now()" at which to call onNext