Hi everyone, I’ve been exploring the new `@Constru...
# multiplatform
d
Hi everyone, I’ve been exploring the new
@ConstructedBy
and
RoomDatabaseConstructor
APIs introduced in Room version
2.7.0-alpha06
. According to the documentation, the
initialize
method of the
RoomDatabaseConstructor
instantiates an implementation of the database. However, there’s also a code snippet provided that shows how
RoomDatabaseConstructor
is used:
Copy code
fun createDatabase(): MusicDatabase {
    return Room.inMemoryDatabaseBuilder<MusicDatabase>(
        factory = MusicDatabaseConstructor::initialize
    ).build()
}
I’m a bit confused here.
initialize
method creates a database instance, and then again the database is created using
Room.databaseBuilder
, which accepts
RoomDatabaseConstructor::initialize
that creates a database instance. Can someone help me understand how this is supposed to work? Specifically, what should happen inside the
initialize
method of
RoomDatabaseConstructor
? Thanks!
👆 1
p
You can forward it to #room
👍 1