Created
August 5, 2019 14:16
-
-
Save HarryTylenol/46ee79ef8d21921c7b7174c40ba5e190 to your computer and use it in GitHub Desktop.
0003_3
This file contains 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
private fun createStateForRequest(request: suspend () -> Unit) = | |
// LiveData (Lifecycle) 2.2.0-alph01 버전 부터 지원 | |
liveData(Dispatchers.IO) { | |
emit(NetworkState.loading) | |
try { | |
request() | |
emit(NetworkState.success) | |
} catch (e: IOException) { | |
e.printStackTrace() | |
emit(NetworkState.failed(e)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment