Created
October 15, 2017 02:08
-
-
Save ar-android/8558d8a590ae356f0e23bfa4d2a19bcb 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 HomeViewModel: ViewModel(){ | |
// Initialize LiveData and MutableLiveData | |
private val actor = actor<Action>(UI, Channel.CONFLATED) { | |
for (action in this) when (action) { | |
is Loadjadwal -> { | |
mutableLoading.value = true | |
try { | |
mutableJadwal.value = JadwalSholatRepository.getJadwalDefault() | |
} catch (e: Exception) { | |
mutableMessage.value = e.message.toString() | |
} | |
mutableLoading.value = false | |
} | |
} | |
} | |
init { | |
action(Loadjadwal("0")) | |
} | |
private fun action(action: Action) = actor.offer(action) | |
override fun onCleared() = actor.cancel().unit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment