Skip to content

Instantly share code, notes, and snippets.

@Garyteck
Created August 14, 2020 05:08
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 Garyteck/4a51250854424d01be2ceb064596dc0f to your computer and use it in GitHub Desktop.
Save Garyteck/4a51250854424d01be2ceb064596dc0f to your computer and use it in GitHub Desktop.
ViewModel Crypto List app
class CryptoViewModel constructor( repository: Repository) : ViewModel()
val cryptos : Flow<PagingData<CryptoCurrency>> = repository.getCryptos()
}
// build.gradle file dependencies
def lifecycle_version = "2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment