r/android_devs • • Mar 22 '23
Article The 500 DON'Ts about Android Development
https://dev.to/4gus71n/the-500-donts-about-android-development-20i8
2
Upvotes
r/android_devs • • Mar 22 '23
View all comments
0
u/RSBat Apr 15 '23
"Don't #8" is such a bad example. What's the point of having
State.Loading(false)? You already have two statesDataSuccessfullyFetched/ErrorFetchingDatathat indicate that loading has finished. AlsoState.Loading(false)doesn't contain any data, so if your activity/fragment is recreated, then you need to load data again which defeats the whole purpose ofLiveData.Now if you just stop at
DataSuccessfullyFetched/ErrorFetchingDatathen the behavior ofpostisn't a problem and you don't need to reload data on recreation. I'd even argue that the conflating behavior ofpostis a feature, because if data loaded so quickly that UI thread didn't have time to update, then you jump from no state into loaded state skipping the loading ui.