package com.zxhl.cms.net.callback;


import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

/**
 * Created by gaoleichao on 2018/6/30.
 */

public abstract class BaseAdOberver<T> implements Observer<T> {

    private Disposable disposable;

    @Override
    public void onNext(@NonNull T result) {
        onSuccess(result);
    }

    @Override
    public void onError(@NonNull Throwable e) {

    }

    @Override
    public void onComplete() {
        if (disposable != null && !disposable.isDisposed()) {
            disposable.dispose();
        }
    }

    @Override
    public void onSubscribe(@NonNull Disposable d) {
        disposable = d;
    }

    public abstract void onSuccess(T result);

    public abstract void onFailure(Throwable e, String code, String errorMsg);
}
