1 | import { PartialObserver, ObservableNotification, CompleteNotification, NextNotification, ErrorNotification } from './types';
|
2 | import { Observable } from './Observable';
|
3 | /**
|
4 | * @deprecated Use a string literal instead. `NotificationKind` will be replaced with a type alias in v8.
|
5 | * It will not be replaced with a const enum as those are not compatible with isolated modules.
|
6 | */
|
7 | export declare enum NotificationKind {
|
8 | NEXT = "N",
|
9 | ERROR = "E",
|
10 | COMPLETE = "C"
|
11 | }
|
12 | /**
|
13 | * Represents a push-based event or value that an {@link Observable} can emit.
|
14 | * This class is particularly useful for operators that manage notifications,
|
15 | * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
|
16 | * others. Besides wrapping the actual delivered value, it also annotates it
|
17 | * with metadata of, for instance, what type of push message it is (`next`,
|
18 | * `error`, or `complete`).
|
19 | *
|
20 | * @see {@link materialize}
|
21 | * @see {@link dematerialize}
|
22 | * @see {@link observeOn}
|
23 | * @deprecated It is NOT recommended to create instances of `Notification` directly.
|
24 | * Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
25 | * For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
26 | * Will be removed in v8.
|
27 | */
|
28 | export declare class Notification<T> {
|
29 | readonly kind: 'N' | 'E' | 'C';
|
30 | readonly value?: T | undefined;
|
31 | readonly error?: any;
|
32 | /**
|
33 | * A value signifying that the notification will "next" if observed. In truth,
|
34 | * This is really synonymous with just checking `kind === "N"`.
|
35 | * @deprecated Will be removed in v8. Instead, just check to see if the value of `kind` is `"N"`.
|
36 | */
|
37 | readonly hasValue: boolean;
|
38 | /**
|
39 | * Creates a "Next" notification object.
|
40 | * @param kind Always `'N'`
|
41 | * @param value The value to notify with if observed.
|
42 | * @deprecated Internal implementation detail. Use {@link Notification#createNext createNext} instead.
|
43 | */
|
44 | constructor(kind: 'N', value?: T);
|
45 | /**
|
46 | * Creates an "Error" notification object.
|
47 | * @param kind Always `'E'`
|
48 | * @param value Always `undefined`
|
49 | * @param error The error to notify with if observed.
|
50 | * @deprecated Internal implementation detail. Use { Notification#createError createError} instead.
|
51 | */
|
52 | constructor(kind: 'E', value: undefined, error: any);
|
53 | /**
|
54 | * Creates a "completion" notification object.
|
55 | * @param kind Always `'C'`
|
56 | * @deprecated Internal implementation detail. Use { Notification#createComplete createComplete} instead.
|
57 | */
|
58 | constructor(kind: 'C');
|
59 | /**
|
60 | * Executes the appropriate handler on a passed `observer` given the `kind` of notification.
|
61 | * If the handler is missing it will do nothing. Even if the notification is an error, if
|
62 | * there is no error handler on the observer, an error will not be thrown, it will noop.
|
63 | * @param observer The observer to notify.
|
64 | */
|
65 | observe(observer: PartialObserver<T>): void;
|
66 | /**
|
67 | * Executes a notification on the appropriate handler from a list provided.
|
68 | * If a handler is missing for the kind of notification, nothing is called
|
69 | * and no error is thrown, it will be a noop.
|
70 | * @param next A next handler
|
71 | * @param error An error handler
|
72 | * @param complete A complete handler
|
73 | * @deprecated Replaced with {in v8.
Notification#observe observe}. Will be removed |
74 | */
|
75 | do(next: (value: T) => void, error: (err: any) => void, complete: () => void): void;
|
76 | /**
|
77 | * Executes a notification on the appropriate handler from a list provided.
|
78 | * If a handler is missing for the kind of notification, nothing is called
|
79 | * and no error is thrown, it will be a noop.
|
80 | * @param next A next handler
|
81 | * @param error An error handler
|
82 | * @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
83 | */
|
84 | do(next: (value: T) => void, error: (err: any) => void): void;
|
85 | /**
|
86 | * Executes the next handler if the Notification is of `kind` `"N"`. Otherwise
|
87 | * this will not error, and it will be a noop.
|
88 | * @param next The next handler
|
89 | * @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
90 | */
|
91 | do(next: (value: T) => void): void;
|
92 | /**
|
93 | * Executes a notification on the appropriate handler from a list provided.
|
94 | * If a handler is missing for the kind of notification, nothing is called
|
95 | * and no error is thrown, it will be a noop.
|
96 | * @param next A next handler
|
97 | * @param error An error handler
|
98 | * @param complete A complete handler
|
99 | * @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
100 | */
|
101 | accept(next: (value: T) => void, error: (err: any) => void, complete: () => void): void;
|
102 | /**
|
103 | * Executes a notification on the appropriate handler from a list provided.
|
104 | * If a handler is missing for the kind of notification, nothing is called
|
105 | * and no error is thrown, it will be a noop.
|
106 | * @param next A next handler
|
107 | * @param error An error handler
|
108 | * @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
109 | */
|
110 | accept(next: (value: T) => void, error: (err: any) => void): void;
|
111 | /**
|
112 | * Executes the next handler if the Notification is of `kind` `"N"`. Otherwise
|
113 | * this will not error, and it will be a noop.
|
114 | * @param next The next handler
|
115 | * @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
116 | */
|
117 | accept(next: (value: T) => void): void;
|
118 | /**
|
119 | * Executes the appropriate handler on a passed `observer` given the `kind` of notification.
|
120 | * If the handler is missing it will do nothing. Even if the notification is an error, if
|
121 | * there is no error handler on the observer, an error will not be thrown, it will noop.
|
122 | * @param observer The observer to notify.
|
123 | * @deprecated Replaced with {@link Notification#observe observe}. Will be removed in v8.
|
124 | */
|
125 | accept(observer: PartialObserver<T>): void;
|
126 | /**
|
127 | * Returns a simple Observable that just delivers the notification represented
|
128 | * by this Notification instance.
|
129 | *
|
130 | * @deprecated Will be removed in v8. To convert a `Notification` to an {@link Observable},
|
131 | * use {@link of} and {@link dematerialize}: `of(notification).pipe(dematerialize())`.
|
132 | */
|
133 | toObservable(): Observable<T>;
|
134 | private static completeNotification;
|
135 | /**
|
136 | * A shortcut to create a Notification instance of the type `next` from a
|
137 | * given value.
|
138 | * @param {T} value The `next` value.
|
139 | * @return {Notification<T>} The "next" Notification representing the
|
140 | * argument.
|
141 | * @nocollapse
|
142 | * @deprecated It is NOT recommended to create instances of `Notification` directly.
|
143 | * Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
144 | * For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
145 | * Will be removed in v8.
|
146 | */
|
147 | static createNext<T>(value: T): Notification<T> & NextNotification<T>;
|
148 | /**
|
149 | * A shortcut to create a Notification instance of the type `error` from a
|
150 | * given error.
|
151 | * @param {any} [err] The `error` error.
|
152 | * @return {Notification<T>} The "error" Notification representing the
|
153 | * argument.
|
154 | * @nocollapse
|
155 | * @deprecated It is NOT recommended to create instances of `Notification` directly.
|
156 | * Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
157 | * For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
158 | * Will be removed in v8.
|
159 | */
|
160 | static createError(err?: any): Notification<never> & ErrorNotification;
|
161 | /**
|
162 | * A shortcut to create a Notification instance of the type `complete`.
|
163 | * @return {Notification<any>} The valueless "complete" Notification.
|
164 | * @nocollapse
|
165 | * @deprecated It is NOT recommended to create instances of `Notification` directly.
|
166 | * Rather, try to create POJOs matching the signature outlined in {@link ObservableNotification}.
|
167 | * For example: `{ kind: 'N', value: 1 }`, `{ kind: 'E', error: new Error('bad') }`, or `{ kind: 'C' }`.
|
168 | * Will be removed in v8.
|
169 | */
|
170 | static createComplete(): Notification<never> & CompleteNotification;
|
171 | }
|
172 | /**
|
173 | * Executes the appropriate handler on a passed `observer` given the `kind` of notification.
|
174 | * If the handler is missing it will do nothing. Even if the notification is an error, if
|
175 | * there is no error handler on the observer, an error will not be thrown, it will noop.
|
176 | * @param notification The notification object to observe.
|
177 | * @param observer The observer to notify.
|
178 | */
|
179 | export declare function observeNotification<T>(notification: ObservableNotification<T>, observer: PartialObserver<T>): void;
|
180 | //# sourceMappingURL=Notification.d.ts.map |
\ | No newline at end of file |