반응형
never
아무것도 통지하지 않은 Flowable/Observable을 생성하는 연산자로, 완료도 통지하지 않는다.
empty는 완료를 통지하지만 never는 아무것도 통지하지 않는다.
[소스코드]
public class Main {
public static void main(String[] args) throws Exception {
never();
}
static void never() throws Exception {
Flowable.never().subscribe(new PrintSubscriber<>());
}
}
[Subscribe 코드]
import io.reactivex.subscribers.DisposableSubscriber;
public class PrintSubscriber<T> extends DisposableSubscriber<T> {
private String label;
public PrintSubscriber() {
}
public PrintSubscriber(String label) {
this.label = label;
}
@Override
public void onNext(T data) {
String threadName = Thread.currentThread().getName();
String resultMsg = label == null ? (threadName + " : " + data) : (threadName + " : "+ label + " : "+ data);
System.out.println(resultMsg);
}
@Override
public void onError(Throwable throwable) {
String threadName = Thread.currentThread().getName();
String resultMsg = label == null ? (threadName + " : Exception=" + throwable) : (threadName + " : "+ label + " : "+ throwable);
System.out.println(resultMsg);
}
@Override
public void onComplete() {
String threadName = Thread.currentThread().getName();
String resultMsg = label == null ? (threadName + " : Complete") : (threadName + " : "+ label + " : Complete");
System.out.println(resultMsg);
}
}
[결과]
없음.
반응형
'Language > Java' 카테고리의 다른 글
[RxJava] flatMap (0) | 2023.04.26 |
---|---|
[RxJava] map (0) | 2023.04.26 |
[RxJava] empty (0) | 2023.04.26 |
[RxJava] defer (0) | 2023.04.26 |
[RxJava] timer (0) | 2023.04.26 |