Documentación RxJS
  • Introducción
  • Operadores
    • Combinación
      • combineAll
      • combineLatest
      • concat
      • concatAll
      • exhaust
      • forkJoin
      • merge
      • mergeAll
      • race
      • startWith
      • switchAll
      • withLatestFrom
      • zip
    • Condicional
      • defaultIfEmpty
      • every
      • find
      • findIndex
      • isEmpty
      • sequenceEqual
    • Creación
      • ajax
      • defer
      • from
      • fromEvent
      • fromEventPattern
      • fromFetch
      • generate
      • iif
      • interval
      • of
      • range
      • throwError
      • timer
    • Gestión de Errores
      • catchError
      • retry
      • retryWhen
    • Filtración
      • audit
      • auditTime
      • debounce
      • debounceTime
      • distinct
      • distinctUntilChanged
      • distinctUntilKeyChanged
      • elementAt
      • filter
      • first
      • ignoreElements
      • last
      • sample
      • sampleTime
      • single
      • skip
      • skipLast
      • skipUntil
      • skipWhile
      • take
      • takeLast
      • takeUntil
      • takeWhile
      • throttle
      • throttleTime
    • Matemáticos y Agregación
      • count
      • max
      • min
      • reduce
    • Multidifusión
      • connect
      • multicast
      • publish
      • publishBehavior
      • publishLast
      • publishReplay
      • refCount
      • share
      • shareReplay
    • Transformación
      • buffer
      • bufferCount
      • bufferTime
      • bufferToggle
      • bufferWhen
      • concatMap
      • concatMapTo
      • exhaust
      • exhaustMap
      • expand
      • groupBy
      • map
      • mapTo
      • mergeMap
      • mergeMapTo
      • mergeScan
      • pairwise
      • partition
      • pluck
      • scan
      • switchMap
      • switchMapTo
      • window
      • windowCount
      • windowTime
      • windowToggle
      • windowWhen
    • Utilidad
      • delay
      • delayWhen
      • dematerialize
      • finalize
      • materialize
      • observeOn
      • repeat
      • repeatWhen
      • subscribeOn
      • tap
      • timeInterval
      • timeout
      • timeoutWith
      • timestamp
      • toArray
  • Conceptos
    • Observables
    • Observadores
    • Operadores
    • Schedulers
    • Sujetos
    • Suscripción
    • Testing de Canicas
  • API
    • Índice
      • ArgumentOutOfRangeError
      • bindCallback
      • bindNodeCallback
      • CompletionObserver
      • config
      • ConnectableObservable
      • EmptyError
      • ErrorObserver
      • FactoryOrValue
      • GroupedObservable
      • identity
      • InteropObservable
      • isObservable
      • MonoTypeOperatorFunction
      • NextObserver
      • noop
      • Notification
      • ObjectUnsubscribedError
      • observable
      • Observable
      • ObservableInput
      • ObservedValueOf
      • ObservedValuesFromArray
      • Observer
      • Operator
      • OperatorFunction
      • PartialObserver
      • pipe
      • scheduled
      • SchedulerAction
      • SchedulerLike
      • Subscribable
      • SubscribableOrPromise
      • Subscriber
      • Subscription
      • SubscriptionLike
      • TeardownLogic
      • TimeInterval
      • TimeoutError
      • Timestamp
      • UnaryFunction
      • Unsubscribable
      • UnsubscriptionError
      • VirtualTimeScheduler
    • ajax
      • AjaxError
      • AjaxRequest
      • AjaxResponse
      • AjaxTimeoutError
    • Schedulers
      • animationFrame
      • asap
      • async
      • queue
    • Sujetos
      • AsyncSubject
      • BehaviorSubject
      • ReplaySubject
      • Subject
      • WebSocketSubject
    • webSocket
      • WebSocketSubjectConfig
    • Testing
  • Guías
    • Glosario
    • Importación
    • Instalación
    • Breaking Changes
      • Argumentos Array
      • Argumentos resultSelector
      • Argumentos scheduler
      • Argumentos subscribe
      • Conversión a Promesas
      • Multicasting
  • Sobre Nosotros
    • El Equipo
    • Código de Conducta
Powered by GitBook
On this page
  • Description
  • Ejemplos
  • Ejemplo de la documentación oficial
  • Recursos adicionales
  1. Operadores
  2. Utilidad

dematerialize

Convierte un Observable de objetos Notification en las emisiones que representan

PreviousdelayWhenNextfinalize

Last updated 2 years ago

Signatura

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.

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)

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

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

const notifA = new Notification("N", "A");
const notifB = new Notification("N", "B");
const notifE = new Notification(
  "E",
  undefined,
  new TypeError("x.toUpperCase is not a function")
);
const materialized = of(notifA, notifB, notifE);
const upperCase = materialized.pipe(dematerialize());
upperCase.subscribe(
  (x) => console.log(x),
  (e) => console.error(e)
);

// Salida:
// A
// B
// TypeError: x.toUpperCase is not a function

Recursos adicionales

Documentación oficial en inglés
StackBlitz
Diagrama de canicas del operador dematerialize
Source code