Previous
A production-level architecture for Android apps (part 1)
Agustín Tomas Larghi ・ F...
For further actions, you may consider blocking this person and/or reporting abuse
Hey!
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.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. 🤓💪
I'm trying to learn from this post while i'm developing an app and i have a situation that i don't know how to solve:
I have two entities (let's say User and Address) and a user has a foreign key to an Address. When i want to save a user i need to create an Address (using AddressRepository) and save a User referencing that address id (using UserRepository). The thing is that i don't know where to put this logic because i need access to two repositories in the same place. As i understand a repository should not have a reference to other repository, but i guess it would neither be correct to do this management from UseCase/Interactor because that would expose how is database implemented. What do you think about it?
I don't see why it would be a bad idea having a
InsertUserWithAddressUseCase
which internally uses two different DB repositories.I'm going to guess that the technology that you're using for the database layer is Room. This is a very brute, raw example of how that would look like, let me know if it fits your needs, or if you're looking for something else:
gist.github.com/4gus71n/2c0b0fe131...
A note though:
Anyone, please feel to drop feedback/questions. I'm always trying to improve in terms of architecture design. 🤓🏗️💪