In this post, as the title suggests, I’ll discuss why one shouldn’t emit View States (or as some people prefer to call it Resource nowadays) from Repository, and why is it Anti-Pattern IMO. While discussing that, this post will also address why returning LiveData from Repository doesn't make sense.
So let us get started by understanding each of the layers in an Android app, and their purposes/function.
Note: I'm not advocating structuring your project by layer here, in-fact I prefer structuring by feature. However, the layers are still there within feature-based modules or packages (in case of monolithic apps).

Layers in a typical Android App

There can be multiple layers in an Android app, however, 3 of them are most significant. …

About

Rivu Chakraborty

Kotlin GDE, Sr. Android Dev @ BYJU’S The Learning App. Author of Reactive Programming in Kotlin, Functional Kotlin, and more books. https://rivu.dev

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