Created
September 3, 2022 01:30
-
-
Save fayaz07/fa13fbf17d59dce5bd3cf3dddeb1b3dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainViewModel(private val todoDao: TodoDao) : ViewModel() { | |
fun getTodos() = todoDao.getList().asLiveData() | |
fun toggleTodoStatus(id: Int, updatedStatus: Boolean) { | |
viewModelScope.launch { | |
todoDao.toggleTodo(id, updatedStatus) | |
} | |
} | |
override fun onCleared() { | |
Log.d("test", "viewmodel destroyed") | |
super.onCleared() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment