Hello all, How I can implement a singleton repo f...
# realm
d
Hello all, How I can implement a singleton repo for Realm to avoid multiple instances for being created?
c
There are different ways you can accomplish this. The easiest is probably putting Realm inside an
object Repo
class, ie..
Copy code
object Repository {
  val realm = Realm.open(...)
}
Then acces it using
Repo.realm
You can also use dependency injection like Koin: https://insert-koin.io/docs/reference/koin-core/definitions/#defining-a-singleton