forked from PacktPublishing/Learning-RxJava-Second-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh8_12.java
More file actions
23 lines (21 loc) · 762 Bytes
/
Copy pathCh8_12.java
File metadata and controls
23 lines (21 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;
public class Ch8_12 {
public static void main(String[] args) {
Flowable<Integer> integers =
Flowable.range(1, 1000)
.subscribeOn(Schedulers.computation());
Observable.just("Alpha", "Beta", "Gamma", "Delta", "Epsilon")
.flatMap(s -> integers.map(i -> i + "-" + s).toObservable())
.subscribe(System.out::println);
sleep(5000);
}
private static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}