dematerialize
Converts an Observable of ObservableNotification objects into the emissions that they represent.
Unwraps ObservableNotification objects as actual next
,
error
and complete
emissions. The opposite of materialize.
dematerialize
is assumed to operate an Observable that only emits
ObservableNotification objects as next
emissions, and does not emit any
error
. Such Observable is the output of a materialize
operation. Those
notifications are then unwrapped using the metadata they contain, and emitted
as next
, error
, and complete
on the output Observable.
Use this operator in conjunction with materialize.
Example
Convert an Observable of Notifications to an actual Observable
import { NextNotification, ErrorNotification, of, dematerialize } from 'rxjs';
const notifA: NextNotification<string> = { kind: 'N', value: 'A' };
const notifB: NextNotification<string> = { kind: 'N', value: 'B' };
const notifE: ErrorNotification = { kind: 'E', error: new TypeError('x.toUpperCase is not a function') };
const materialized = of(notifA, notifB, notifE);
const upperCase = materialized.pipe(dematerialize());
upperCase.subscribe({
next: x => console.log(x),
error: e => console.error(e)
});
// Results in:
// A
// B
// TypeError: x.toUpperCase is not a function
function dematerialize<N extends ObservableNotification<any>>(): OperatorFunction<N, ValueFromNotification<N>>;
§
dematerialize<N extends ObservableNotification<any>>(): OperatorFunction<N, ValueFromNotification<N>>
[src]§Type Parameters
§
N extends ObservableNotification<any>
[src]