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.56k stars 671 forks source link

How about making the example do modifications? #49

Open teemobean opened 3 years ago

teemobean commented 3 years ago

This is an interesting model (I'm looking at the MVVM version)

Would you be able to implement updates via the UI into CoreData? It looks like the sample implementation implements the read path. I'd be curious how the write path works, specifically:

  1. I'm curious how you would implement TextField updates (for example, to let the user change the name of a country). Simple implementations would bind the TextField to the View Model and then (maybe?) use a combine pipeline to write updates to the view model to the DB. How would you convert this to an action?
  2. I'm also curious how you would handle CoreData synchronizations from iCloud. How does this model detect changes coming from the user (user edits the country) and thus the change needs to flow to CoreData, vs a change that happens in CoreData (maybe they have the app loaded on another device and changed the country there) needing to update the UI. How would you handle conflicts in this model?

Thank you for the cool work!

nalexn commented 3 years ago

These are great questions @teemobean , I apologize for not providing the answers yet, as they need quite some time investment, which I currently cannot afford. Stay tuned!