1 import { Observer, PartialObserver } from './types';
2 import { Subscription } from './Subscription';
4 * Implements the {@link Observer} interface and extends the
5 * {@link Subscription} class. While the {@link Observer} is the public API for
6 * consuming the values of an {@link Observable}, all Observers get converted to
7 * a Subscriber, in order to provide Subscription-like capabilities such as
8 * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
9 * implementing operators, but it is rarely used as a public API.
11 * @class Subscriber<T>
13 export declare class Subscriber<T> extends Subscription implements Observer<T> {
15 * A static factory for a Subscriber, given a (potentially partial) definition
17 * @param {function(x: ?T): void} [next] The `next` callback of an Observer.
18 * @param {function(e: ?any): void} [error] The `error` callback of an
20 * @param {function(): void} [complete] The `complete` callback of an
22 * @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
23 * Observer represented by the given arguments.
26 static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T>;
27 /** @internal */ syncErrorValue: any;
28 /** @internal */ syncErrorThrown: boolean;
29 /** @internal */ syncErrorThrowable: boolean;
30 protected isStopped: boolean;
31 protected destination: PartialObserver<any> | Subscriber<any>;
33 * @param {Observer|function(value: T): void} [destinationOrNext] A partially
34 * defined Observer or a `next` callback function.
35 * @param {function(e: ?any): void} [error] The `error` callback of an
37 * @param {function(): void} [complete] The `complete` callback of an
40 constructor(destinationOrNext?: PartialObserver<any> | ((value: T) => void), error?: (e?: any) => void, complete?: () => void);
42 * The {@link Observer} callback to receive notifications of type `next` from
43 * the Observable, with a value. The Observable may call this method 0 or more
45 * @param {T} [value] The `next` value.
48 next(value?: T): void;
50 * The {@link Observer} callback to receive notifications of type `error` from
51 * the Observable, with an attached `Error`. Notifies the Observer that
52 * the Observable has experienced an error condition.
53 * @param {any} [err] The `error` exception.
56 error(err?: any): void;
58 * The {@link Observer} callback to receive a valueless notification of type
59 * `complete` from the Observable. Notifies the Observer that the Observable
60 * has finished sending push-based notifications.
65 protected _next(value: T): void;
66 protected _error(err: any): void;
67 protected _complete(): void;
68 /** @deprecated This is an internal implementation detail, do not use. */
69 _unsubscribeAndRecycle(): Subscriber<T>;
72 * We need this JSDoc comment for affecting ESDoc.
76 export declare class SafeSubscriber<T> extends Subscriber<T> {
77 private _parentSubscriber;
79 constructor(_parentSubscriber: Subscriber<T>, observerOrNext?: PartialObserver<T> | ((value: T) => void), error?: (e?: any) => void, complete?: () => void);
80 next(value?: T): void;
81 error(err?: any): void;
84 private __tryOrSetError;
85 /** @internal This is an internal implementation detail, do not use. */