https://kotlinlang.org logo
#feed
Title
# feed
k

Kanchan Pal

11/29/2020, 12:16 PM
#android #jetpack #clean architecture  Hi All, Check out an article explaining well defined android architecture components. Hope it helps people looking to create similar projects for learning a good android application development. https://kanchan-pal.medium.com/news-android-app-607f9dc6a3d1 Project link: https://github.com/kanch231004/News-Feed Surely your claps and starring the project if you find it helpful would be motivating for future articles and projects https://www.linkedin.com/feed/update/urn:li:activity:6738782661868867584
j

Joost Klitsie

11/29/2020, 5:38 PM
I have some questions: Is there a reason to use LiveData in your repositories? Usually repositories do not have a lifecycle, and if you observe/interact with it from a view model (which also doesn't have a lifecycle) it is maybe a better idea to not put livedata inside the viewmodel. Also, why do you pass an io context from your viewmodel to the repository? Shouldn't the component which uses disk i/o be responsible to use the correct context? Now you have to have prior knowledge that you should call the repo to add an IO scope, in turn the repo has to be aware of the datasource to also use IO. I guess it'd be better to directly inject the ioScope only at the point where you use it.
d

Daniel

11/29/2020, 10:36 PM
I hope you can see this as a code review, not big critique: Too many dependencies for such a small usecase. You don't need Databindung, you don't need AndroidInjection stuff, ect. Architecture is all over the place, for example in
NewsListFragment
->
val data = viewModel.newsList(isConnected
the View tells the ViewModel what to do. Followed by the ViewModel putting implementaion details (IO scope) into the repository. While simultaniously putting a boolean into the same function which originated in the view. Thats from 5 min code review. Best take a look at this project again and keep one thing in mind: Keep it simple
5 Views