I have a kmm app on swiftui and kotlin.
My problem is that whenever I try to do a logout and then logging in back, the realm sync will not open or work. The realm will work only if I close the app and re-open the app.
Also, when starting the app on the login page, everything works fine, so the problem its when doing the logout.
On the logout I do a reset of the repo, I re-initialize the object:
func doLogout(){
repo.doLogout(){error in
SingletonRepo.reset()
UserDefaults.standard.set(false, forKey: "isLogin")
isLoginShown = true
}
}
the SingletonRepo with the reset method:
class SingletonRepo{
static var shared = RealmRepo()
private init() { }
static func reset() {
shared = RealmRepo()
}
The reset will re-initialize the shared Kotlin RealmRepo(). I do this for the next user to have a new Realm Repo instance.
Is this the correct flow?
Shouldnt I reset the realm repo when doing the logout?
Should I close it? Should I close the repo and then reset it?
What is the correct flow?
Thank you for your time!