I have to do some initial setup each time the app starts, but I'm getting the error:
The error is clear, the answer is not. I tried putting the init in a subview, but I can't, it needs to be in the root @main
. This is how I have it defined:
@StateObject private var amplifyConfig: AmplifyConfig = AmplifyConfig()
init() {
if(amplifyConfig.isAmplifyConfigured == false) {
amplifyConfig.dataStoreHubEventSubscriber()
amplifyConfig.configureAmplify()
}
}
How do I get rid of that warning and actually implement it so it doesn't create multiple instances, at the end of the day that's why I'm using @EnvironmentObject for?