Subject so that it is safe to call its various on methods from different threads.
When you use an ordinary Subject as a Subscriber, you must take care not to call its
Subscriber#onNext method (or its other on methods) from multiple threads, as this could lead
to non-serialized calls, which violates the
Observable contract and creates an ambiguity in the resulting Subject.
To protect a Subject from this danger, you can convert it into a SerializedSubject with code
like the following:
mySafeSubject = new SerializedSubject( myUnsafeSubject );
| Modifier and Type | Field and Description |
|---|---|
| private final Subject | |
| private final SerializedObserver |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | hasObservers()
Implements abstract rx. Subject has Observers subscribed to it.
|
| public void | onCompleted()
Implements rx. Observable has finished sending push-based notifications.
|
| public void | onError(Throwable
the exception encountered by the Observable e)Implements rx. Observable has experienced an error condition.
|
| public void | onNext(T
the item emitted by the Observable t)Implements rx. |
| actual | back to summary |
|---|---|
| private final Subject<T, R> actual | |
| observer | back to summary |
|---|---|
| private final SerializedObserver<T> observer | |
| SerializedSubject | back to summary |
|---|---|
| public SerializedSubject(final Subject<T, R> actual) | |
| hasObservers | back to summary |
|---|---|
| public boolean hasObservers() Implements abstract rx. Doc from rx. Indicates whether the
| |
| onCompleted | back to summary |
|---|---|
| public void onCompleted() Implements rx. Doc from rx. Notifies the Observer that the
The
| |
| onError | back to summary |
|---|---|
| public void onError(Throwable e) Implements rx. Doc from rx. Notifies the Observer that the
If the | |
| onNext | back to summary |
|---|---|
| public void onNext(T t) Implements rx. Doc from rx. Provides the Observer with a new item to observe.
The
The
| |