Learn RxJS
Search…
dematerialize

signature: dematerialize(): Observable

Turn notification objects into notification values.

Examples

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

Additional Resources

Last modified 1yr ago