The dematerialize
operator is used to convert a higher-order Observable, which emits Notification objects as its items, into a lower-order Observable that emits the items from the source Observable. This can be useful when working with temporal operators such as delay
or buffer
, where we might want to revert the Notification objects back into their original Observable/stream form.
Here's an example of how to use the dematerialize
operator in JavaScript:
index.tsx410 chars17 lines
In this example, we create an Observable source
that emits the values 1, 2, and 3, with a delay of 2 seconds between each emission. We then apply the materialize
operator to convert these emissions into Notification objects.
We then create a new Observable example
that converts these Notification objects back into their original form using the dematerialize
operator. Finally, we subscribe to example
and log out each emission as well as the completion message.
Output:
index.tsx16 chars5 lines
gistlibby LogSnag