Skip to content

Instantly share code, notes, and snippets.

@MamboBryan
Created May 21, 2022 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MamboBryan/732e5e3e85d5f9b8c05c57a7f08bc4de to your computer and use it in GitHub Desktop.
Save MamboBryan/732e5e3e85d5f9b8c05c57a7f08bc4de to your computer and use it in GitHub Desktop.
The viewmodel
package com.mambobryan.samba.ui.characters
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.cachedIn
import com.mambobryan.samba.data.repositories.CharactersRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class CharactersViewModel @Inject constructor(
repository: CharactersRepository
) : ViewModel(){
val articles = repository.getCharacters().cachedIn(viewModelScope)
val articlesWithCache = repository.getCharactersWithCache().cachedIn(viewModelScope)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment