dematerialize

signature: dematerialize(): Observable

Turn notification objects into notification values.

Examples

Example 1: Converting notifications to values

( jsBin | jsFiddle )

import { from } 'rxjs/observable/from';
import { Notification } from 'rxjs/Notification';

//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


:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/patching/operator/demterialize.ts

results matching ""

    No results matching ""