Observer
An interface for a consumer of push-based notifications delivered by an Observable.
interface Observer<T> {
closed?: boolean;
next: (value: T) => void;
error: (err: any) => void;
complete: () => void;
}
An object conforming to the Observer interface is usually
given to the observable.subscribe(observer) method, and the Observable will
call the Observer's next(value) method to provide notifications. A
well-behaved Observable will call an Observer's complete() method exactly
once or the Observer's error(err) method exactly once, as the last
notification delivered.
Member Summary
| Public Members | ||
| public |
An optional flag to indicate whether this Observer, when used as a subscriber, has already been unsubscribed from its Observable. |
|
Method Summary
| Public Methods | ||
| public |
complete(): void The callback to receive a valueless notification of type |
|
| public |
error(err: any): void The callback to receive notifications of type |
|
| public |
next(value: T): void The callback to receive notifications of type |
|
Public Members
Public Methods
public complete(): void source
The callback to receive a valueless notification of type complete from
the Observable. Notifies the Observer that the Observable has finished
sending push-based notifications.
Return:
| void |
public error(err: any): void source
The callback to receive notifications of type error from the Observable,
with an attached Error. Notifies the Observer that the Observable
has experienced an error condition.
Params:
| Name | Type | Attribute | Description |
| err | any | The |
Return:
| void |
public next(value: T): void source
The callback to receive notifications of type next from the Observable,
with a value. The Observable may call this method 0 or more times.
Params:
| Name | Type | Attribute | Description |
| value | T | The |
Return:
| void |