Slide 29
Slide 29 text
How OnSubscribe works
Observable.range(1, 5)
.subscribe(
i -> Log.i(TAG, "Output: " + i),
throwable -> Log.e(TAG, "Error: ", throwable),
() -> Log.i(TAG, “Completed.")
);
@Override
public void call(Subscriber super Integer> subscriber) {
for (int i = start; i < start + count; i++) {
if (subscriber.isUnsubscribed()) {
return;
}
subscriber.onNext(i);
}
if (!subscriber.isUnsubscribed()) {
subscriber.onCompleted();
}
}