1 import { PartialObserver } from './types';
2 import { Observable } from './Observable';
4 * @deprecated NotificationKind is deprecated as const enums are not compatible with isolated modules. Use a string literal instead.
6 export declare enum NotificationKind {
12 * Represents a push-based event or value that an {@link Observable} can emit.
13 * This class is particularly useful for operators that manage notifications,
14 * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
15 * others. Besides wrapping the actual delivered value, it also annotates it
16 * with metadata of, for instance, what type of push message it is (`next`,
17 * `error`, or `complete`).
19 * @see {@link materialize}
20 * @see {@link dematerialize}
21 * @see {@link observeOn}
23 * @class Notification<T>
25 export declare class Notification<T> {
26 kind: 'N' | 'E' | 'C';
30 constructor(kind: 'N' | 'E' | 'C', value?: T, error?: any);
32 * Delivers to the given `observer` the value wrapped by this Notification.
33 * @param {Observer} observer
36 observe(observer: PartialObserver<T>): any;
38 * Given some {@link Observer} callbacks, deliver the value represented by the
39 * current Notification to the correctly corresponding callback.
40 * @param {function(value: T): void} next An Observer `next` callback.
41 * @param {function(err: any): void} [error] An Observer `error` callback.
42 * @param {function(): void} [complete] An Observer `complete` callback.
45 do(next: (value: T) => void, error?: (err: any) => void, complete?: () => void): any;
47 * Takes an Observer or its individual callback functions, and calls `observe`
48 * or `do` methods accordingly.
49 * @param {Observer|function(value: T): void} nextOrObserver An Observer or
50 * the `next` callback.
51 * @param {function(err: any): void} [error] An Observer `error` callback.
52 * @param {function(): void} [complete] An Observer `complete` callback.
55 accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void): any;
57 * Returns a simple Observable that just delivers the notification represented
58 * by this Notification instance.
61 toObservable(): Observable<T>;
62 private static completeNotification;
63 private static undefinedValueNotification;
65 * A shortcut to create a Notification instance of the type `next` from a
67 * @param {T} value The `next` value.
68 * @return {Notification<T>} The "next" Notification representing the
72 static createNext<T>(value: T): Notification<T>;
74 * A shortcut to create a Notification instance of the type `error` from a
76 * @param {any} [err] The `error` error.
77 * @return {Notification<T>} The "error" Notification representing the
81 static createError<T>(err?: any): Notification<T>;
83 * A shortcut to create a Notification instance of the type `complete`.
84 * @return {Notification<any>} The valueless "complete" Notification.
87 static createComplete(): Notification<any>;