Example 1: Converting notifications to values
( StackBlitz | jsBin | jsFiddle )
// RxJS v6+import { from, Notification } from 'rxjs';import { dematerialize } from 'rxjs/operators';//emit next and error notificationsconst source = from([Notification.createNext('SUCCESS!'),Notification.createError('ERROR!')]).pipe(//turn notification objects into notification valuesdematerialize());//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}`)});
dematerialize 📰 - Official
docs
📁 Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/demterialize.ts