some serious issue in viewModel
razaghimahdi opened this issue · comments
rq_mehdi commented
so when i try to multi trigger events it doesnt work correctly, for example i was testing BlogViewModel in init method i called some onTriggerEvent on purpose, then i find out list sets empty, why this happened? what we should do to solve that?
rq_mehdi commented
so finally after two days i think i got solution:
i tied to use old fashioned way
i deleted:
this.state.value = state.copy(
order = order,
filter = filter
)
and used this:
fun getCurrentViewStateOrNew(): BlogState{
val value = state.value?.let{
it
}?: BlogState()
return value
}
fun setViewState(viewState: BlogState){
state.value = viewState
}
i have no idea why this works and why that one doesn't works,
any idea?