Observer.
Example usage:
// observer will receive all 4 events (including "default").
BehaviorSubject<Object> subject = BehaviorSubject.create("default");
subject.subscribe(observer);
subject.onNext("one");
subject.onNext("two");
subject.onNext("three");
// observer will receive the "one", "two" and "three" events, but not "default" and "zero"
BehaviorSubject<Object> subject = BehaviorSubject.create("default");
subject.onNext("zero");
subject.onNext("one");
subject.subscribe(observer);
subject.onNext("two");
subject.onNext("three");
// observer will receive only onCompleted
BehaviorSubject<Object> subject = BehaviorSubject.create("default");
subject.onNext("zero");
subject.onNext("one");
subject.onCompleted();
subject.subscribe(observer);
// observer will receive only onError
BehaviorSubject<Object> subject = BehaviorSubject.create("default");
subject.onNext("zero");
subject.onNext("one");
subject.onError(new RuntimeException("error"));
subject.subscribe(observer);
| Modifier and Type | Field and Description |
|---|---|
| private static final Object[] | EMPTY_ARRAY
An empty array to trigger getValues() to return a new array. |
| private final SubjectSubscriptionManager |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static < the type of item the Subject will emit T> BehaviorSubject | |
| public static < the type of item the Subject will emit T> BehaviorSubject | Returns: the constructedBehaviorSubjectthe item that will be emitted first to any defaultValue)Observer as long as the
BehaviorSubject has not yet observed any items from its source ObservableCreates a |
| private static <T> BehaviorSubject | |
| public Throwable | Returns: the Throwable that terminated the Subject ornull if the
subject hasn't terminated yet or it terminated normally.Returns the Throwable that terminated the Subject. |
| public T | Returns: the current value ornull if the Subject doesn't have a value,
has terminated or has an actual null as a valid value.Returns the current value of the Subject if there is such a value and the subject hasn't terminated yet. |
| public T[] | Returns: the arraya if it had enough capacity or a new array containing the available valuesthe array to fill in a)Returns a snapshot of the currently buffered non-terminal events into
the provided |
| public Object[] | Returns: a snapshot of the currently buffered non-terminal events.Returns a snapshot of the currently buffered non-terminal events. |
| public boolean | Returns: true if the subject completed normally viaonCompleted()Check if the Subject has terminated normally. |
| public boolean | hasObservers()
Implements abstract rx. Subject has Observers subscribed to it.
|
| public boolean | Returns: true if the subject has received a throwable throughonError.Check if the Subject has terminated with an exception. |
| public boolean | Returns: true if and only if the subject has some value and hasn't terminated yet.Check if the Subject has a value. |
| 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 v)Implements rx. |
| pack-priv int |
| EMPTY_ARRAY | back to summary |
|---|---|
| private static final Object[] EMPTY_ARRAY An empty array to trigger getValues() to return a new array. | |
| state | back to summary |
|---|---|
| private final SubjectSubscriptionManager<T> state | |
| BehaviorSubject | back to summary |
|---|---|
| protected BehaviorSubject(Observable. | |
| create | back to summary |
|---|---|
| public static <T> BehaviorSubject Creates a
| |
| create | back to summary |
|---|---|
| public static <T> BehaviorSubject Creates a
| |
| create | back to summary |
|---|---|
| private static <T> BehaviorSubject | |
| getThrowable | back to summary |
|---|---|
| public Throwable getThrowable() Returns the Throwable that terminated the Subject.
| |
| getValue | back to summary |
|---|---|
| public T getValue() Returns the current value of the Subject if there is such a value and the subject hasn't terminated yet. The method can return
| |
| getValues | back to summary |
|---|---|
| public T[] getValues(T[] a) Returns a snapshot of the currently buffered non-terminal events into
the provided
| |
| getValues | back to summary |
|---|---|
| public Object[] getValues() Returns a snapshot of the currently buffered non-terminal events. The operation is thread-safe.
| |
| hasCompleted | back to summary |
|---|---|
| public boolean hasCompleted() Check if the Subject has terminated normally.
| |
| hasObservers | back to summary |
|---|---|
| public boolean hasObservers() Implements abstract rx. Doc from rx. Indicates whether the
| |
| hasThrowable | back to summary |
|---|---|
| public boolean hasThrowable() Check if the Subject has terminated with an exception.
| |
| hasValue | back to summary |
|---|---|
| public boolean hasValue() Check if the Subject has a value. Use the Note that unless
| |
| 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 v) Implements rx. Doc from rx. Provides the Observer with a new item to observe.
The
The
| |
| subscriberCount | back to summary |
|---|---|
| pack-priv int subscriberCount() | |