forked from PacktPublishing/Learning-RxJava-Second-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh2_30b.java
More file actions
16 lines (15 loc) · 674 Bytes
/
Copy pathCh2_30b.java
File metadata and controls
16 lines (15 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import io.reactivex.rxjava3.core.Observable;
public class Ch2_30b {
public static void main(String[] args) {
// has emission
Observable<Integer> source = Observable.just(100);
source.subscribe(s -> System.out.println("Process 1: " + s),
e -> System.out.println("Error captured: " + e),
() -> System.out.println("Process 1 done!"));
//no emission
Observable<Integer> empty = Observable.empty();
empty.subscribe(s -> System.out.println("Process 2: " + s),
e -> System.out.println("Error captured: " + e),
() -> System.out.println("Process 2 done!"));
}
}