package com.gh.gamecenter.gamecollection.choose

import android.annotation.SuppressLint
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.retrofit.RetrofitManager

class AddHotGamesViewModel(application: Application) : AndroidViewModel(application) {
    private val mApi = RetrofitManager.getInstance().newApi
    val tabListLiveData = MutableLiveData<List<SubjectEntity>?>()

    init {
        getHotColumns()
    }

    @SuppressLint("CheckResult")
    fun getHotColumns() {
        mApi.hotColumns
            .compose(singleToMain())
            .subscribe({
                tabListLiveData.postValue(it)
            }, {
                tabListLiveData.postValue(null)
            })
    }
}