Skip to content

Instantly share code, notes, and snippets.

@annchar
Created June 6, 2021 09:44
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 annchar/f7c97a3030c8b7e12e71ce8b839ee117 to your computer and use it in GitHub Desktop.
Save annchar/f7c97a3030c8b7e12e71ce8b839ee117 to your computer and use it in GitHub Desktop.
class CryptoListViewModel(private val repository: CryptoListRepository) : BaseViewModel() {
private val _cryptoList = MutableLiveData<PagingData<CryptoItemResponse>>()
suspend fun getCryptoList(): LiveData<PagingData<CryptoItemResponse>> {
val response = repository.getCryptoList().cachedIn(viewModelScope)
_cryptoList.value = response.value
return response
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment