nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decouple `Respository` logic

jbatra-umeey opened this issue · comments

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.

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.