package com.colorful.keyboard.theme.net;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import rx.subscriptions.CompositeSubscription;

public class BaseInitApiRequest {

    public static ApiStores mHyyApiStores;

    private static  CompositeSubscription mCompositeSubscription;

    public static ApiStores initHHYApiStores() {
        if(null == mHyyApiStores){
            mHyyApiStores = AppClient.getWorkerRetrofit().create(ApiStores.class);
        }
        return mHyyApiStores;
    }

    public static void getNetData(Observable observable, Subscriber subscriber) {

        if (mCompositeSubscription == null) {
            mCompositeSubscription = new CompositeSubscription();
        }

        mCompositeSubscription.add(observable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber));


    }
}
