Great article. Just to note that I think the logic part (the loadData() part) should be done in a ViewModel to preserve it’s state, because the fragment might be destroyed in the middle of loading the data, but we still want to see the result when it is recreated, and also, we can map the data to a LiveData and observe it on the fragment side.

--

--

Android Team Lead at Tapsi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store