Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Parent DataHolder for easy implementation of DataHolder for Activities.
open class AacMviDH<STATE, EFFECT> {
private val _states: MutableLiveData<STATE> = MutableLiveData()
val stateLiveData: LiveData<STATE>
get() = _states
private var _state: STATE? = null
var state: STATE
get() = _state
?: throw UninitializedPropertyAccessException("\"state\" was queried before being initialized")
set(value) {
Log.d(TAG, "setting viewState : $value")
_state = value
_states.value = value
private val _effects: SingleLiveEvent<EFFECT> = SingleLiveEvent()
val effectLiveData: SingleLiveEvent<EFFECT>
get() = _effects
var effect: EFFECT? = null
set(value) {
Log.d(TAG, "setting viewEffect : $value")
field = value
_effects.value = value
fun onCleared() {
_state = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment