Skip to content

Instantly share code, notes, and snippets.

@Foreman76
Created April 15, 2021 07:49
Show Gist options
  • Save Foreman76/8a6d401d32626f68783dae7855268089 to your computer and use it in GitHub Desktop.
Save Foreman76/8a6d401d32626f68783dae7855268089 to your computer and use it in GitHub Desktop.
package ru.int24.ownbarbershop.fragments.viewmodels
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import ru.int24.ownbarbershop.models.domen.DomSettings
import ru.int24.ownbarbershop.repositories.UsesCaseBaseRepositoryImpl
import javax.inject.Inject
class VMMainActivity @Inject constructor(private val usesCaseBaseRepositoryImpl: UsesCaseBaseRepositoryImpl): ViewModel() {
private val _isSettingsFromDB: MutableLiveData<DomSettings?> = MutableLiveData()
fun getSettingsFromDB(){
viewModelScope.launch(Dispatchers.Main) {
_isSettingsFromDB.postValue(usesCaseBaseRepositoryImpl.getAllSettings())
}
}
fun getSettingsFromVM(): LiveData<DomSettings?> = _isSettingsFromDB
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment