Skip to content

Instantly share code, notes, and snippets.

@shorthouse
Created January 31, 2025 21:24
Show Gist options
  • Save shorthouse/f81ab94ef7ecd95202b6230b5564bb80 to your computer and use it in GitHub Desktop.
Save shorthouse/f81ab94ef7ecd95202b6230b5564bb80 to your computer and use it in GitHub Desktop.
class MovieViewModel(private val movieDao: MovieDao): ViewModel() {
// ...
fun updateMovieName(newText: TextFieldValue) {
_movieName.value = newText
}
fun insertMovie(movieName: String) {
viewModelScope.launch {
movieDao.insert(Movie(name = movieName))
}
}
fun deleteMovies() {
viewModelScope.launch {
movieDao.deleteMovies()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment