package com.kfzs.libs.convert;

import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by guoxin on 2018/4/4.
 */

public class HttpObservableTransformer implements Observable.Transformer{

    private HttpObserver httpObserver;

    public HttpObservableTransformer(HttpObserver httpObserver){
        this.httpObserver = httpObserver;
    }

    @Override
    public Object call(Object observable) {
        return ((Observable) observable).subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(httpObserver);
    }

}
