jungwoon.github.io/rxjava2/2019/07/05/RxJava-1/
www.vogella.com/tutorials/RxJava/article.html : 많은 예시와 how to
Observable<Integer> source = Observable.create(subscriber -> {
try {
if (!subscriber.isUnsubscribed()) {
for (int i = 1; i < 5; i++) {
subscriber.onNext(i);
}
subscriber.onCompleted();
}
} catch (Exception e) {
subscriber.onError(e);
}
});
source.subscribe(
i -> System.out.println("Next: " + i),
e -> System.err.println("Error: " + e),
() -> System.out.println("Completed"));
결과
Next: 1
Next: 2
Next: 3
Next: 4
Completed