Yacov Rosenberg
04/28/2023, 4:42 PM@Provides
@Singleton
fun provideLocalRealm(config: RealmConfiguration): Realm {
return Realm.open(config)
}
And inject it in my use cases...
But I'm receiveing a error
java.lang.IllegalStateException: Scoped provider was invoked recursively returning different results: RealmImpl[/data/user/0/ee.visittallinn.tallinncard.dev/files/REALM_LOCAL}] & RealmImpl[/data/user/0/ee.visittallinn.tallinncard.dev/files/REALM_LOCAL}]. This is likely due to a circular dependency.
As I understood from documentation we could open the realm once and keep it as a singleton in the application lifecycle.
Or I should open every time I need to use it and only inject the RealmConfiguration...?chrmelchior
05/01/2023, 10:07 AMRealm.open()
multiple times will return different instances, but I would assume that the @Singleton
anotation cached the result? 🤔
But yes, you should be able to cache the result of Realm.open()
and use it throughout.Yacov Rosenberg
05/04/2023, 12:48 PM