class stable
Implements the Observer interface and extends the Subscription class. While the Observer is the public API for consuming the values of an Observable, all Observers get converted to a Subscriber, in order to provide Subscription-like capabilities such as unsubscribe. Subscriber is a common type in RxJS, and crucial for implementing operators, but it is rarely used as a public API.
class Subscriber<T> extends Subscription implements Observer {
static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T>
constructor(destinationOrNext?: PartialObserver<any> | ((value: T) => void), error?: (e?: any) => void, complete?: () => void)
protected isStopped: boolean
protected destination: PartialObserver<any> | Subscriber<any>
next(value?: T): void
error(err?: any): void
complete(): void
unsubscribe(): void
protected _next(value: T): void
protected _error(err: any): void
protected _complete(): void
_unsubscribeAndRecycle(): Subscriber<T>
// inherited from index/Subscription
static EMPTY: Subscription
constructor(unsubscribe?: () => void)
closed: [object Object]
unsubscribe(): void
add(teardown: TeardownLogic): Subscription
remove(subscription: Subscription): void
} A static factory for a Subscriber, given a (potentially partial) definition of an Observer.
static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T>| next | Optional. Default is The |
| error | Optional. Default is The |
| complete | Optional. Default is The |
Subscriber<T>: A Subscriber wrapping the (partially defined) Observer represented by the given arguments.
constructor(destinationOrNext?: PartialObserver<any> | ((value: T) => void), error?: (e?: any) => void, complete?: () => void)| destinationOrNext | Optional. Default is A partially defined Observer or a |
| error | Optional. Default is The |
| complete | Optional. Default is The |
| Property | Type | Description |
|---|---|---|
| isStopped | boolean | |
| destination | PartialObserver<any> | Subscriber<any> |
next(value?: T): voidThe Observer callback to receive notifications of type next from the Observable, with a value. The Observable may call this method 0 or more times.
| value | Optional. Default is The |
void:
error(err?: any): voidThe Observer 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.
| err | Optional. Default is The |
void:
complete(): voidThe Observer callback to receive a valueless notification of type complete from the Observable. Notifies the Observer that the Observable has finished sending push-based notifications.
There are no parameters.
void:
unsubscribe(): voidThere are no parameters.
void
protected _next(value: T): void| value | Type: |
void
protected _error(err: any): void| err | Type: |
void
protected _complete(): voidThere are no parameters.
void
_unsubscribeAndRecycle(): Subscriber<T>There are no parameters.
Subscriber<T>
© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/index/class/Subscriber