I’ve been trying to prepopulate my DB with a RoomD...
# koin
m
I’ve been trying to prepopulate my DB with a RoomDatabase.Callbac() and I see that it is only populated if I fetch the data first (just like it was some sort of lazy way). The problem is that once it’s populated, I don’t get the data back. In theory, it should be prepopulated the first time the DB is initialized, and I’m doing so in a Koin module:
Copy code
val databaseModule = module {
    single { HeritageDatabase.getDatabase(get()) }
    single { get<HeritageDatabase>().heritageDao() }
}
d
single
has a parameter called
createdAtStart
, which is
false
by default. However I would argue that this is abusing DI. Dependency definitions (like
single
) shouldn't really have side-effects like that.
👍 1