I have the following class:
final class NetworkController: ObservableObject {
init() {
if #available(iOS 15.0, *) {
print("⚠️ Inside init")
Task(priority: .medium){
await configureAmplify()
await checkUserSignedIn()
}
} else {
print(" Failed to Initialize Amplify")
}
}
@Published var authState: AuthState = .guess // Observes state changes in the session
...
}
If I try to initialize it to access some function inside, like this:
final class DataStorePersistanceHandler: ObservableObject {
var networkController = NetworkController()
...
}
I get the NetworkController
class looping multiple times, my guess is that it's recreating the view and therefore calling it multiple times, so my question is, how can I initialize it without doing so? I just want to have it initialized for when I need it.
Thanks