package org.ntlab.developrx; import org.ntlab.developrx.utils.ThreadUtil; import io.reactivex.subscribers.DisposableSubscriber; /** * デバッグ用のSubscriber * * Created by matsumoto_k on 2017/11/12. */ public class DebugSubscriber<T> extends DisposableSubscriber<T> { private String label; public DebugSubscriber(String label) { this.label = label; } @Override public void onNext(T data) { if (label == null) { System.out.println(ThreadUtil.getCurrentThreadName() + ": " + data); } else { System.out.println(ThreadUtil.getCurrentThreadName() + ": " + label + ": " + data); } } @Override public void onError(Throwable throwable) { if (label == null) { System.out.println(ThreadUtil.getCurrentThreadName() + ": エラー=" + throwable); } else { System.out.println(ThreadUtil.getCurrentThreadName() + ": " + label + ": エラー= " + throwable); } } @Override public void onComplete() { if (label == null) { System.out.println(ThreadUtil.getCurrentThreadName() + ": 完了"); } else { System.out.println(ThreadUtil.getCurrentThreadName() + ": " + label + ": 完了"); } } }