is this how I would model the state for a list of results?
data class EventsState(
val events: List<EventComponent> = listOf(),
val isLoading: Boolean = true,
val errors: Errors = Errors.None
)
back in my switch case, I have a case for
isLoading
, another case for
events.isNotEmpty()
, another for
errors.throwable != null
and the final
else
where I’m assuming the events list is empty
the issue is, when I first load up, and while the events list is coming back, I get the empty state
why is that?
isLoading
starts off as true and the
only time it becomes false is when the events come back, I update the state along with the isLoading in 1 go, when is it getting the chance to fall into the else?
eventsState.value =
eventsState.value.copy(events = it, isLoading = false, errors = Errors.None)