Skip to content

Instantly share code, notes, and snippets.

@gastsail
Last active March 5, 2020 23:25
Show Gist options
  • Save gastsail/8898ed39c24fe3e77dcde06afe2df5e0 to your computer and use it in GitHub Desktop.
Save gastsail/8898ed39c24fe3e77dcde06afe2df5e0 to your computer and use it in GitHub Desktop.
class MainViewModel(repo:Repo):ViewModel() {
val fetchVersionCode = liveData(Dispatchers.IO) {
emit(Resource.Loading())
try{
repo.getVersionCode().collect {
emit(it)
}
}catch (e: Exception){
emit(Resource.Failure(e))
Log.e("ERROR:",e.message)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment