package com.app.baselibrary.baseRx;

import com.app.baselibrary.base.app.BaseApplication;
import com.app.baselibrary.commonUtil.NetWorkUtils;

import rx.Subscriber;

/**
 * Desc: 对订阅者的进一步封装；只是针对网络请求进行的进一步封装；
 * Author: pl
 * Date: 2017-04-13 17:46
 */

public abstract class RxSubscriber<T> extends Subscriber<T> {


    @Override
    public void onCompleted() {

    }

    @Override
    public void onError(Throwable e) {

        if (!NetWorkUtils.isNetConnected(BaseApplication.getAppContext())) {
            _noNet();
        } else {
            _onError(e);
        }
    }

    @Override
    public void onNext(T t) {
        _onNext(t);
    }

    protected abstract void _noNet();

    protected abstract void _onNext(T t);

    protected abstract void _onError(Throwable e);
}
