dematerialize

signature: dematerialize(): Observable

Turn notification objects into notification values.

dematerialize - 图1

Examples

Example 1: Converting notifications to values

( jsBin |
jsFiddle )

  1. import { from } 'rxjs/observable/from';
  2. import { Notification } from 'rxjs/Notification';
  3. //emit next and error notifications
  4. const source = from([
  5. Notification.createNext('SUCCESS!'),
  6. Notification.createError('ERROR!')
  7. ]).pipe(
  8. //turn notification objects into notification values
  9. dematerialize()
  10. )
  11. //output: 'NEXT VALUE: SUCCESS' 'ERROR VALUE: 'ERROR!'
  12. const subscription = source.subscribe({
  13. next: val => console.log(`NEXT VALUE: ${val}`),
  14. error: val => console.log(`ERROR VALUE: ${val}`)
  15. });

Additional Resources


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