DEV Community

Discussion on: A production-level architecture for Android apps (part 2)

Collapse
 
zhuinden profile image
Gabor Varadi

Hey!

private fun observeQueryChanges() {
    viewModel.searchParams.observe(this, Observer {
        viewModel.searchPosts(it)
    })
}

This can actually be moved into Transformations.switchMap(searchParams) { searchPosts(it) } inside the ViewModel. That way you don't need to observe the changes here, you can just observe the posts themselves.

Collapse
 
4gus71n profile image
Agustín Tomas Larghi

Thanks for the feedback! Totally, there are a few things that I could improve on this architecture, I need to update a few things here though, for example, I've changed a bit the API of the Interactors so I can actually dispose them when the ViewModel gets destroyed.

Please let me know if you see anything else that you think could be improved. 🤓💪