So what's the solution for using MVVM in a setup where you're using EnvironmentObject to pass in access to the model?
I'm thinking of something like Core Data where you can use an EnvironmentObject to pass in an NSManagedObjectContext. You can't create an @EnvironmentObject ViewModel in init because the EnvironmentObject isn't set yet. And the EnvironmentObject property's didSet doesn't fire so you can't do it there.
Creating the ViewModel in onAppear works but seems a bit clumsy. Is that the best way to do this?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: