-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRxJavaSample18.java
More file actions
34 lines (25 loc) · 968 Bytes
/
RxJavaSample18.java
File metadata and controls
34 lines (25 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import rx.Observable;
import rx.Subscriber;
import java.util.Arrays;
import java.util.List;
public class RxJavaSample18 {
public static void main(String[] args) {
Observable.just("Hello, world!")
.map(s -> potentialException(s))
.map(s -> anotherPotentialException(s))
.subscribe(new Subscriber<String>() {
@Override
public void onNext(String s) { System.out.println(s); }
@Override
public void onCompleted() { System.out.println("Completed!"); }
@Override
public void onError(Throwable e) { System.out.println("Ouch!"); }
});
}
private static String potentialException(String s) {
return "potentialException - " + s;
}
private static String anotherPotentialException(String s) {
return "anotherPotentialException - " + s;
}
}