In
Chapter 5
, Testing RxPHP Code, when we talked about testing in RxPHP, we weren't using real values, and instead were passing some special recorded objects that wrapped the actual value with OnNextNotification
(or its error
or complete
variants). We did this because of the TestScheduler
class and because we had to be able to uniquely identify each value in order to compare object references and not just their values. Comparing just values wouldn't guarantee that they are identical because primitive types such as strings or integers aren't passed by reference by default.
There are two operators that use a similar principle. These are materialize()
and dematerialize()
.
The first one takes each value, wraps it with a notification object, and re-emits it as a typical onNext
signal. This includes error
and complete
signals as well. These are wrapped and re-emitted like any other value, and after that a complete signal is sent.
This means we can...