-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample2.java
More file actions
38 lines (32 loc) · 1.11 KB
/
example2.java
File metadata and controls
38 lines (32 loc) · 1.11 KB
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
35
36
37
38
import rx.Observable;
import rx.functions.Action0;
import rx.functions.Action1;
public class example2 {
public static void main(String[] args){
Integer[] numbers = {0,1,2,3,4,5,6,7};
numberFlow(numbers);
}
private static void numberFlow(Integer[] nums){
Observable numberObservable = Observable.from(nums);
numberObservable.subscribe(
new Action1<Integer>(){
@Override
public void call(Integer integer) {
System.out.println(integer);
}
},
new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
System.out.println("Error in synchronous observable");
}
},
new Action0() {
@Override
public void call() {
System.out.println("This observable is finished");
}
}
);
}
}