Last active
March 5, 2020 23:25
-
-
Save gastsail/8898ed39c24fe3e77dcde06afe2df5e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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