I'm struggling to find the best architectural solution for my Swift code. My project is based on three fundamental approaches:
- SwiftUI,
- MVVM,
- and using an ObservableObject only when a state is needed.
However, I'm facing an issue where my ViewModels have redundant business logic, such as authentication. There are a couple of views that need to handle and check authentication or refresh the token.
To solve this problem, I've thought about creating a class called AuthenticationLogic to handle all the logic related to authentication. This would allow my ViewModel to handle only the UI interaction. However, I'm not sure if this is the best approach and I'm worried that it might be an anti-pattern.
So, I'm looking for guidance on the best architectural way to solve this redundancy in logic between ViewModels.
I tried creating logic class but seems its an ant-pattern. I am expecting theoretical answer or a codable solution
Aucun commentaire:
Enregistrer un commentaire