forked from PacktPublishing/Learning-RxJava-Second-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh3_69.java
More file actions
22 lines (19 loc) · 627 Bytes
/
Copy pathCh3_69.java
File metadata and controls
22 lines (19 loc) · 627 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import io.reactivex.rxjava3.core.Observable;
import java.util.concurrent.TimeUnit;
public class Ch3_69 {
public static void main(String[] args) {
Observable.interval(2, TimeUnit.SECONDS)
.doOnNext(i -> System.out.println("Emitted: " + i))
.take(3)
.timeInterval(TimeUnit.SECONDS)
.subscribe(i -> System.out.println("Received: " + i));
sleep(7000);
}
private static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}