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