Throughout this book, we emphasized the push-based nature of an Observable. Pushing items synchronously and one at a time from the source all the way to the Observer is indeed how an Observable chain of operators works by default without any concurrency.
For instance, the following demonstrates an Observable that emits the numbers from 1 through 999,999,999:
import io.reactivex.rxjava3.core.Observable;
public class Ch8_01 {
public static void main(String[] args) {
Observable.range(1, 999_999_999)
.map(MyItem::new)
.subscribe(myItem -> {
sleep(50);
System.out.println("Received MyItem " + myItem.id);
});
}
}
It maps each integer to a MyItem instance, which simply holds it as a property:
static final class MyItem {
final int id;
MyItem...