Top Description Inners Fields Constructors Methods
rx.subjects

public final Class PublishSubject<T>

extends Subject<T, T>
Class Inheritance
Type Parameters
<T>
the type of items observed and emitted by the Subject
Imports
java.util.*, java.util.concurrent.atomic.*, rx.*, .Observer, rx.exceptions.*, rx.internal.operators.BackpressureUtils

Subject that, once an Observer has subscribed, emits all subsequently observed items to the subscriber.

Example usage:

 PublishSubject<Object> subject = PublishSubject.create();
 // observer1 will receive all onNext and onCompleted events
 subject.subscribe(observer1);
 subject.onNext("one");
 subject.onNext("two");
 // observer2 will only receive "three" and onCompleted
 subject.subscribe(observer2);
 subject.onNext("three");
 subject.onCompleted();

  

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final PublishSubject.PublishSubjectState<T>

Constructor Summary

AccessConstructor and Description
protected

Method Summary

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

Returns:

the new PublishSubject
create
()

Creates and returns a new PublishSubject.

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 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 void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(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
v
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
Inherited from rx.subjects.Subject:
toSerialized

Field Detail

stateback to summary
pack-priv final PublishSubject.PublishSubjectState<T> state

Constructor Detail

PublishSubjectback to summary
protected PublishSubject(PublishSubject.PublishSubjectState<T> state)

Method Detail

createback to summary
public static <T> PublishSubject<T> create()

Creates and returns a new PublishSubject.

Parameters
<T>
the value type
Returns:PublishSubject<T>

the new PublishSubject

getThrowableback to summary
public Throwable getThrowable()

Returns the Throwable that terminated the Subject.

Returns:Throwable

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

Since
1.2
hasCompletedback to summary
public boolean hasCompleted()

Check if the Subject has terminated normally.

Returns:boolean

true if the subject completed normally via onCompleted

Since
1.2
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
hasThrowableback to summary
public boolean hasThrowable()

Check if the Subject has terminated with an exception.

Returns:boolean

true if the subject has received a throwable through onError.

Since
1.2
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T v)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
v:T

the item emitted by the Observable

Annotations
@Override
rx.subjects back to summary

pack-priv final Class PublishSubject.PublishSubjectProducer<T>

extends AtomicLong
implements Producer, Subscription, Observer<T>
Class Inheritance
All Implemented Interfaces
rx.Observer, rx.Subscription, rx.Producer

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super T>
pack-priv final PublishSubject.PublishSubjectState<T>
pack-priv long
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(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 void
request(long
the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace
n
)

Implements rx.Producer.request.

Request a certain maximum number of items from this Producer.
public void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
Inherited from java.util.concurrent.atomic.AtomicLong:
accumulateAndGetaddAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetdecrementAndGetdoubleValuefloatValuegetgetAcquiregetAndAccumulategetAndAddgetAndDecrementgetAndIncrementgetAndSetgetAndUpdategetOpaquegetPlainincrementAndGetintValuelazySetlongValuesetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

actualback to summary
pack-priv final Subscriber<? super T> actual
parentback to summary
pack-priv final PublishSubject.PublishSubjectState<T> parent
producedback to summary
pack-priv long produced
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicLong.serialVersionUID.

Constructor Detail

PublishSubjectProducerback to summary
public PublishSubjectProducer(PublishSubject.PublishSubjectState<T> parent, Subscriber<? super T> actual)

Method Detail

isUnsubscribedback to summary
public boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
requestback to summary
public void request(long n)

Implements rx.Producer.request.

Doc from rx.Producer.request.

Request a certain maximum number of items from this Producer. This is a way of requesting backpressure. To disable backpressure, pass Long.MAX_VALUE to this method.

Requests are additive but if a sequence of requests totals more than Long.MAX_VALUE then Long.MAX_VALUE requests will be actioned and the extras may be ignored. Arriving at Long.MAX_VALUE by addition of requests cannot be assumed to disable backpressure. For example, the code below may result in Long.MAX_VALUE requests being actioned only.

request(100);
request(Long.MAX_VALUE-1);
Parameters
n:long

the maximum number of items you want this Producer to produce, or Long.MAX_VALUE if you want the Producer to produce items at its own pace

Annotations
@Override
unsubscribeback to summary
public void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

This allows deregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

Annotations
@Override
rx.subjects back to summary

pack-priv final Class PublishSubject.PublishSubjectState<T>

extends AtomicReference<PublishSubject.PublishSubjectProducer<T>[]>
implements Observable.OnSubscribe<T>, Observer<T>
Class Inheritance
All Implemented Interfaces
rx.Observer, rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action, rx.functions.Function

Field Summary

Modifier and TypeField and Description
pack-priv static final PublishSubject.PublishSubjectProducer<T>[]
pack-priv Throwable
private static final long
pack-priv static final PublishSubject.PublishSubjectProducer<T>[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
public void
call(Subscriber<? super T> t)

Implements rx.functions.Action1.call.

public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(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.
pack-priv void
Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

EMPTYback to summary
pack-priv static final PublishSubject.PublishSubjectProducer<T>[] EMPTY
Annotations
@SuppressWarnings:rawtypes
errorback to summary
pack-priv Throwable error
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

TERMINATEDback to summary
pack-priv static final PublishSubject.PublishSubjectProducer<T>[] TERMINATED
Annotations
@SuppressWarnings:rawtypes

Constructor Detail

PublishSubjectStateback to summary
public PublishSubjectState()
Annotations
@SuppressWarnings:unchecked

Method Detail

addback to summary
pack-priv boolean add(PublishSubject.PublishSubjectProducer<T> inner)
callback to summary
public void call(Subscriber<? super T> t)

Implements rx.functions.Action1.call.

Annotations
@Override
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@SuppressWarnings:unchecked
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@SuppressWarnings:unchecked
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
removeback to summary
pack-priv void remove(PublishSubject.PublishSubjectProducer<T> inner)
Annotations
@SuppressWarnings:unchecked