Colton Idle
12/14/2022, 4:04 AMColton Idle
12/14/2022, 4:06 AMeygraber
12/14/2022, 4:37 AMRepository pattern and "use cases" pattern
Doesn't have to be those two specifically, but some kind of arch like that is the solution here
alex.krupa
12/14/2022, 4:38 AMFrancesc
12/14/2022, 4:44 AMColton Idle
12/14/2022, 4:46 AMalex.krupa
12/14/2022, 4:48 AMFrancesc
12/14/2022, 4:56 AMFrancesc
12/14/2022, 4:58 AMalex.krupa
12/14/2022, 5:04 AMalex.krupa
12/14/2022, 5:05 AMPablichjenkov
12/14/2022, 5:37 AMTash
12/14/2022, 8:24 AMJavier
12/14/2022, 8:38 AMjulioromano
12/14/2022, 8:39 AMCsaba Szugyiczki
12/14/2022, 8:48 AMCompose onClick() -> VM.doSomething() -> Model.fetchData() -> modify internal state (StateFlow)
Compose dataState = VM.data.collectAsState() <- VM.data = Model.getDataFlow() <- Model.getDataFlow = internal state (StateFlow)
Csaba Szugyiczki
12/14/2022, 8:50 AMCasey Brooks
12/14/2022, 3:29 PMFrancesc
12/14/2022, 4:06 PM@Francesc what do you mean by “middleware” in this context?in MVI a middleware is a component that accepts some of the intents and executes async work
Francesc
12/14/2022, 4:13 PMInstead, I’ve found it much more helpful to think of the Repository layer as the important piece of your app that holds and manages data, and the API/DB are simply data sources that it may be interacting with. I start with defining the models I want to work with in my app, and then build the Repository layer to fetch/cache/translate the API/DB models into that ideal form.I have worked on projects that do this as well and has helped, however we do not do this at the repository layer, we do this at the interactors (also known as use cases). These aggregate data from 1 or multiple repositories, and map it to a data model that the viewmodel expects (so the viewmodel does not have a direct dependency on the repositories but only on the interactors), and then the viewmodel can pass this data to the UI with minimum manipulation
Casey Brooks
12/14/2022, 4:18 PMwe do this at the interactors (also known as use cases)Yeah, I’m moving toward that terminology as well. As a general principle, i still prefer to call it the “Repository Layer”, which can (optionally) be broken down into smaller “use-cases”. I haven’t quite figured out the architecture I’m happy with yet for how to manage many interrelated use cases in large apps, though.