30 lines
867 B
Kotlin
30 lines
867 B
Kotlin
|
|
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
|
||
|
|
fun provideLocalDataSource(credentialDao: CredentialDao): LocalDataSource {
|
||
|
|
return LocalDataSource(credentialDao)
|
||
|
|
}
|
||
|
|
}
|