30 lines
894 B
Kotlin
Raw Normal View History

2026-06-09 16:27:40 +07:00
package com.longnh15.heimdall.di
import android.content.Context
import androidx.room.Room
import com.longnh15.heimdall.data.source.local.CredentialDao
import com.longnh15.heimdall.data.source.local.HeimdallDatabase
import com.longnh15.heimdall.data.source.local.LocalDataSource
import org.koin.core.annotation.Module
import org.koin.core.annotation.Single
@Module
class DatabaseModule {
@Single
fun provideDatabase(context: Context): HeimdallDatabase =
Room.databaseBuilder(
context,
HeimdallDatabase::class.java,
"heimdall.db"
).build()
@Single
fun provideCredentialDao(db: HeimdallDatabase): CredentialDao {
return db.credentialDao()
}
@Single
2026-06-17 16:19:10 +07:00
fun provideLocalDataSource(credentialDao: CredentialDao, context: Context): LocalDataSource {
return LocalDataSource(credentialDao, context)
2026-06-09 16:27:40 +07:00
}
}