package com.various.funny.sounds.audio.ui.fragment

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.various.funny.sounds.audio.data.NewBeanChild
import com.various.funny.sounds.audio.db.MyRoomBase
import kotlinx.coroutines.launch

class CollectViewModel : ViewModel() {
    private   var _mdata: MutableLiveData<List<NewBeanChild>> = MutableLiveData<List<NewBeanChild>>()

    init {
        viewModelScope.launch {
            _mdata.value = MyRoomBase.dataBase.getNewBeanChildDao().getCollectData()
        }
    }

    fun update(){
        viewModelScope.launch {
            _mdata.value = MyRoomBase.dataBase.getNewBeanChildDao().getCollectData()
        }
    }

    fun getList() = _mdata

    override fun onCleared() {
        super.onCleared()
    }

}