UNPKG

3.57 kBTypeScriptView Raw
1import { Observer } from './types';
2import { Subscription } from './Subscription';
3/**
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.
10 *
11 * @class Subscriber<T>
12 */
13export declare class Subscriber<T> extends Subscription implements Observer<T> {
14 /**
15 * A static factory for a Subscriber, given a (potentially partial) definition
16 * of an Observer.
17 * @param next The `next` callback of an Observer.
18 * @param error The `error` callback of an
19 * Observer.
20 * @param complete The `complete` callback of an
21 * Observer.
22 * @return A Subscriber wrapping the (partially defined)
23 * Observer represented by the given arguments.
24 * @nocollapse
25 * @deprecated Do not use. Will be removed in v8. There is no replacement for this
26 * method, and there is no reason to be creating instances of `Subscriber` directly.
27 * If you have a specific use case, please file an issue.
28 */
29 static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T>;
30 /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
31 protected isStopped: boolean;
32 /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
33 protected destination: Subscriber<any> | Observer<any>;
34 /**
35 * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
36 * There is no reason to directly create an instance of Subscriber. This type is exported for typings reasons.
37 */
38 constructor(destination?: Subscriber<any> | Observer<any>);
39 /**
40 * The {@link Observer} callback to receive notifications of type `next` from
41 * the Observable, with a value. The Observable may call this method 0 or more
42 * times.
43 * @param {T} [value] The `next` value.
44 * @return {void}
45 */
46 next(value?: T): void;
47 /**
48 * The {@link Observer} callback to receive notifications of type `error` from
49 * the Observable, with an attached `Error`. Notifies the Observer that
50 * the Observable has experienced an error condition.
51 * @param {any} [err] The `error` exception.
52 * @return {void}
53 */
54 error(err?: any): void;
55 /**
56 * The {@link Observer} callback to receive a valueless notification of type
57 * `complete` from the Observable. Notifies the Observer that the Observable
58 * has finished sending push-based notifications.
59 * @return {void}
60 */
61 complete(): void;
62 unsubscribe(): void;
63 protected _next(value: T): void;
64 protected _error(err: any): void;
65 protected _complete(): void;
66}
67export declare class SafeSubscriber<T> extends Subscriber<T> {
68 constructor(observerOrNext?: Partial<Observer<T>> | ((value: T) => void) | null, error?: ((e?: any) => void) | null, complete?: (() => void) | null);
69}
70/**
71 * The observer used as a stub for subscriptions where the user did not
72 * pass any arguments to `subscribe`. Comes with the default error handling
73 * behavior.
74 */
75export declare const EMPTY_OBSERVER: Readonly<Observer<any>> & {
76 closed: true;
77};
78//# sourceMappingURL=Subscriber.d.ts.map
\No newline at end of file