forked from PacktPublishing/Learning-RxJava-Second-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh2_07.java
More file actions
33 lines (29 loc) · 1018 Bytes
/
Copy pathCh2_07.java
File metadata and controls
33 lines (29 loc) · 1018 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
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
public class Ch2_07 {
public static void main(String[] args) {
Observable<String> source =
Observable.just("Alpha", "Beta", "Gamma");
Observer<Integer> myObserver = new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
//do nothing with Disposable, disregard for now
}
@Override
public void onNext(Integer value) {
System.out.println("RECEIVED: " + value);
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onComplete() {
System.out.println("Done!");
}
};
source.map(String::length).filter(i -> i >= 5)
.subscribe(myObserver);
}
}