added a databasewrapper to inject a nullable value
FIX for Web - done
This commit is contained in:
parent
9917d2beb9
commit
d2db7275d5
8 changed files with 23 additions and 10 deletions
|
@ -3,14 +3,16 @@ package com.surrus.common.repository
|
|||
import co.touchlab.kermit.LogcatLogger
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.squareup.sqldelight.android.AndroidSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual fun platformModule() = module {
|
||||
single {
|
||||
val driver =
|
||||
AndroidSqliteDriver(PeopleInSpaceDatabase.Schema,get(), "peopleinspace.db")
|
||||
PeopleInSpaceDatabase(driver)
|
||||
AndroidSqliteDriver(PeopleInSpaceDatabase.Schema, get(), "peopleinspace.db")
|
||||
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package com.surrus.common.di
|
||||
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
|
||||
class PeopleInSpaceDatabaseWrapper(val instance: PeopleInSpaceDatabase?)
|
|
@ -3,6 +3,7 @@ package com.surrus.common.repository
|
|||
import co.touchlab.kermit.Kermit
|
||||
import com.squareup.sqldelight.runtime.coroutines.asFlow
|
||||
import com.squareup.sqldelight.runtime.coroutines.mapToList
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.common.model.personBios
|
||||
import com.surrus.common.model.personImages
|
||||
import com.surrus.common.remote.Assignment
|
||||
|
@ -24,8 +25,8 @@ class PeopleInSpaceRepository : KoinComponent {
|
|||
private val logger: Kermit by inject()
|
||||
|
||||
private val coroutineScope: CoroutineScope = MainScope()
|
||||
private val peopleInSpaceDatabase : PeopleInSpaceDatabase? by inject()
|
||||
private val peopleInSpaceQueries = peopleInSpaceDatabase?.peopleInSpaceQueries
|
||||
private val peopleInSpaceDatabase : PeopleInSpaceDatabaseWrapper by inject()
|
||||
private val peopleInSpaceQueries = peopleInSpaceDatabase.instance?.peopleInSpaceQueries
|
||||
|
||||
var peopleJob: Job? = null
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ package com.surrus.common.repository
|
|||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.NSLogLogger
|
||||
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual fun platformModule() = module {
|
||||
single {
|
||||
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
|
||||
PeopleInSpaceDatabase(driver)
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@ package com.surrus.common.repository
|
|||
|
||||
import co.touchlab.kermit.CommonLogger
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual fun platformModule() = module {
|
||||
single<PeopleInSpaceDatabase?> {
|
||||
null
|
||||
single {
|
||||
PeopleInSpaceDatabaseWrapper(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.surrus.common.repository
|
|||
import co.touchlab.kermit.CommonLogger
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
import org.koin.dsl.module
|
||||
|
||||
|
@ -12,6 +13,6 @@ actual fun platformModule() = module {
|
|||
single {
|
||||
val driver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
|
||||
.also { PeopleInSpaceDatabase.Schema.create(it) }
|
||||
PeopleInSpaceDatabase(driver)
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
}
|
|
@ -3,13 +3,14 @@ package com.surrus.common.repository
|
|||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.NSLogLogger
|
||||
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual fun platformModule() = module {
|
||||
single {
|
||||
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
|
||||
PeopleInSpaceDatabase(driver)
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ package com.surrus.common.repository
|
|||
import co.touchlab.kermit.Logger
|
||||
import co.touchlab.kermit.NSLogLogger
|
||||
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
|
||||
import com.surrus.common.di.PeopleInSpaceDatabaseWrapper
|
||||
import com.surrus.peopleinspace.db.PeopleInSpaceDatabase
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual fun platformModule() = module {
|
||||
single {
|
||||
val driver = NativeSqliteDriver(PeopleInSpaceDatabase.Schema, "peopleinspace.db")
|
||||
PeopleInSpaceDatabase(driver)
|
||||
PeopleInSpaceDatabaseWrapper(PeopleInSpaceDatabase(driver))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue