package com.quansu.heifengwuliu.repository

import android.annotation.SuppressLint
import com.quansu.heifengwuliu.model.User
import com.quansu.heifengwuliu.utils.net.NetEngine
import com.ysnows.base.base.BRepository
import io.reactivex.Observable

class HomeRepository : BRepository() {

    @SuppressLint("CheckResult")
    fun getUserInfo(): Observable<User?> {
        return Observable.create<User?> { emitter ->
            lreq(NetEngine.service.getUser())
                    .doOnNext {
                        if (it.ok()) {
                            it.data()?.save()
                            emitter.onNext(it.data()!!)
                        }
                    }
                    .subscribe();
        }


    }


}
