dematerialize
RxJS 5 dematerialize
by Brian Troncone
HTML
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.8/dist/global/Rx.umd.js"></script>
JavaScript
//emit next and error notifications
const source = Rx.Observable
.from([
Rx.Notification.createNext('SUCCESS!'),
Rx.Notification.createError('ERROR!')
])
//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}`)
});