dematerialize

signature: dematerialize(): Observable

Turn notification objects into notification values.

UltimateRxJSarrow-up-right

Examples

Example 1: Converting notifications to values

( StackBlitzarrow-up-right | jsBinarrow-up-right | jsFiddlearrow-up-right )

// RxJS v6+
import { from, Notification } from 'rxjs';
import { dematerialize } from 'rxjs/operators';

//emit next and error notifications
const source = from([
  Notification.createNext('SUCCESS!'),
  Notification.createError('ERROR!')
]).pipe(
  //turn notification objects into notification values
  dematerialize()
);

//output: 'NEXT VALUE: SUCCESS' 'ERROR VALUE: 'ERROR!'
const subscription = source.subscribe({
  next: val => console.log(`NEXT VALUE: ${val}`),
  error: val => console.log(`ERROR VALUE: ${val}`)
});

Additional Resources

📁 Source Code: https://github.com/ReactiveX/rxjs/blob/master/packages/rxjs/src/internal/operators/demterialize.tsarrow-up-right

Last updated