UNPKG

1.89 kBTypeScriptView Raw
1import { OperatorFunction, ObservableNotification, ValueFromNotification } from '../types';
2/**
3 * Converts an Observable of {@link ObservableNotification} objects into the emissions
4 * that they represent.
5 *
6 * <span class="informal">Unwraps {@link ObservableNotification} objects as actual `next`,
7 * `error` and `complete` emissions. The opposite of {@link materialize}.</span>
8 *
9 * ![](dematerialize.png)
10 *
11 * `dematerialize` is assumed to operate an Observable that only emits
12 * {@link ObservableNotification} objects as `next` emissions, and does not emit any
13 * `error`. Such Observable is the output of a `materialize` operation. Those
14 * notifications are then unwrapped using the metadata they contain, and emitted
15 * as `next`, `error`, and `complete` on the output Observable.
16 *
17 * Use this operator in conjunction with {@link materialize}.
18 *
19 * ## Example
20 *
21 * Convert an Observable of Notifications to an actual Observable
22 *
23 * ```ts
24 * import { of } from 'rxjs';
25 * import { dematerialize } from 'rxjs/operators';
26 *
27 * const notifA = { kind: 'N', value: 'A' };
28 * const notifB = { kind: 'N', value: 'B' };
29 * const notifE = { kind: 'E', error: new TypeError('x.toUpperCase is not a function') }
30 *
31 * const materialized = of(notifA, notifB, notifE);
32 *
33 * const upperCase = materialized.pipe(dematerialize());
34 * upperCase.subscribe({
35 * next: x => console.log(x),
36 * error: e => console.error(e)
37 * });
38 *
39 * // Results in:
40 * // A
41 * // B
42 * // TypeError: x.toUpperCase is not a function
43 * ```
44 * @see {@link materialize}
45 *
46 * @return A function that returns an Observable that emits items and
47 * notifications embedded in Notification objects emitted by the source
48 * Observable.
49 */
50export declare function dematerialize<N extends ObservableNotification<any>>(): OperatorFunction<N, ValueFromNotification<N>>;
51//# sourceMappingURL=dematerialize.d.ts.map
\No newline at end of file