forked from Froussios/Intro-To-RxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintSubscriber.java
More file actions
41 lines (30 loc) · 877 Bytes
/
Copy pathPrintSubscriber.java
File metadata and controls
41 lines (30 loc) · 877 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
35
36
37
38
39
40
41
package subscriber;
import io.reactivex.MaybeObserver;
import io.reactivex.Observer;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;
public class PrintSubscriber implements Observer, SingleObserver, MaybeObserver {
private final String name;
public PrintSubscriber(String name) {
this.name = name;
}
@Override
public void onSubscribe(final Disposable d) {
}
@Override
public void onSuccess(final Object o) {
System.out.println(name + ": Success: " + o);
}
@Override
public void onNext(final Object o) {
System.out.println(name + ": " + o);
}
@Override
public void onError(final Throwable e) {
System.out.println(name + ": Error: " + e);
}
@Override
public void onComplete() {
System.out.println(name + ": Completed");
}
}