nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
MIT License
5.73k stars 697 forks source link

Decouple `Respository` logic #92

Open jbatra-umeey opened 10 months ago

jbatra-umeey commented 10 months ago

Greetings @nalexn,

I'm currently working on the task of disentangling the database/Appstate from the CountriesInteractor. However, it appears that the two are closely intertwined. Could you kindly provide some guidance on how to achieve this separation, or if there are any sample examples available without this coupling, that would be greatly appreciated?

I went through the below description and it seems Appstate is available by default

Previously, this app did not use CoreData for persistence, and all loaded data were stored in the AppState.

With the persistence layer in place we have a choice - either to load the DB content onto the AppState, or serve the data from Interactors on an on-demand basis through Binding.

The first option suits best when you don't have a lot of data, for example, when you just store the last used login email in the UserDefaults. Then, the corresponding string value can just be loaded onto the AppState at launch and updated by the Interactor when the user changes the input.

nalexn commented 10 months ago

Yep, did you check that v1 of the app under the "previously" link? It did not use core data and was using app state solely.