dematerialize

Convierte un Observable de objetos Notification en las emisiones que representan

chevron-rightSignaturahashtag

Firma

dematerialize<T>(): OperatorFunction<Notification<T>, T>

Parámetros

No recibe ningún parámetro.

Retorna

OperatorFunction<Notification<T>, T>: Un Observable que emite elementos y notificaciones embebidos en objetos Notification emitidos por el Observable fuente.

Description

Transforma los objetos Notification en emisiones next, error y complete. Es el operador opuesto a materialize.

Diagrama de canicas del operador dematerialize

dematerialize opera un Observable que únicamente emite objetos Notification como emisiones next, y no emite ningún error. Tal Observable es el resultado de una operación con materialize. Esas notificaciones se transforman mediante los metadatos que contienen, y se emiten como notificaciones next, error y complete en el Observable salida.

Se utiliza junto al operador materialize.

Ejemplos

Convierte las Notificaciones en emisiones con el mismo valor y tipo (error, next o complete)

StackBlitzarrow-up-right

import { dematerialize } from "rxjs/operators";
import { of, Notification } from "rxjs";

const notification$ = of(
  Notification.createNext("RxJS mola"),
  Notification.createError(new Error("¡Oh no!"))
);

// Emitirá objetos Notification
notification$.subscribe(console.log);
/* Salida: 
Notification { kind: 'N', value: 'RxJS is cool', error: undefined, ... }, 
Notification { kind: 'E', value: undefined, error: {...}, ...}
*/

// Al usar dematerialize, emitirá el valor de la notificación
notification$.pipe(dematerialize()).subscribe(console.log, console.error);
// Salida: RxJS is cool, (error) Oh noez!

Ejemplo de la documentación oficial

Convierte un Observable de Notificaciones en un Observable de valores

Recursos adicionales

Source codearrow-up-right

Documentación oficial en inglésarrow-up-right

Last updated