The materialize() operator takes the three events onNext(), onComplete(), and onError(), and turns all of them into emissions wrapped in Notification<T>. So if your source emits five emissions, you will get six emissions where the last one will be onComplete() or onError(). In the following code, we materialize Observable emitting five strings, which are turned into six Notification emissions:
import io.reactivex.rxjava3.core.Observable;
public class D_01 {
public static void main(String[] args) {
Observable<String> source = Observable.just("Alpha", "Beta",
"Gamma", "Delta", "Epsilon");
source.materialize().subscribe(System.out::println);
}
}
The output is as follows:
OnNextNotification[Alpha]
OnNextNotification[Beta]
OnNextNotification...