dematerialize

签名: dematerialize(): Observable

将 notification 对象转换成 notification 值。

dematerialize - 图1

示例

示例 1: 将 notifications 转换成值。

( jsBin |
jsFiddle )

  1. import { from } 'rxjs/observable/from';
  2. import { Notification } from 'rxjs/Notification';
  3. // 发出 next 和 error 通知
  4. const source = from([
  5. Notification.createNext('SUCCESS!'),
  6. Notification.createError('ERROR!')
  7. ]).pipe(
  8. // 将 notification 对象转换成 notification 值
  9. dematerialize()
  10. )
  11. // 输出: '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. });

其他资源


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