mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
feat(folio-core): scope Repository and SqlLedgerStore as @SingleIn(AppScope)
Both are app-wide singletons so the SqlDelight-backed flows remain shared across the graph.
This commit is contained in:
1 parent
4bc8da8ee1
commit
783fb9804e
2 files changed
+6
No files matched your search
@@ -1,9 +1,12 @@
|
|||||||
package app.folio.core.data
|
package app.folio.core.data
|
||||||
|
|
||||||
import app.folio.core.platform.Platform
|
import app.folio.core.platform.Platform
|
||||||
|
import dev.zacsweers.metro.AppScope
|
||||||
import dev.zacsweers.metro.Inject
|
import dev.zacsweers.metro.Inject
|
||||||
|
import dev.zacsweers.metro.SingleIn
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
|
||||||
|
@SingleIn(AppScope::class)
|
||||||
@Inject
|
@Inject
|
||||||
class Repository(private val store: LedgerStore) {
|
class Repository(private val store: LedgerStore) {
|
||||||
val accounts: StateFlow<List<Account>> = store.accounts
|
val accounts: StateFlow<List<Account>> = store.accounts
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import app.cash.sqldelight.coroutines.asFlow
|
|||||||
import app.cash.sqldelight.coroutines.mapToList
|
import app.cash.sqldelight.coroutines.mapToList
|
||||||
import app.cash.sqldelight.coroutines.mapToOneOrNull
|
import app.cash.sqldelight.coroutines.mapToOneOrNull
|
||||||
import app.folio.db.LedgerDatabase
|
import app.folio.db.LedgerDatabase
|
||||||
|
import dev.zacsweers.metro.AppScope
|
||||||
import dev.zacsweers.metro.Inject
|
import dev.zacsweers.metro.Inject
|
||||||
|
import dev.zacsweers.metro.SingleIn
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
@@ -14,6 +16,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
|
||||||
|
@SingleIn(AppScope::class)
|
||||||
@Inject
|
@Inject
|
||||||
class SqlLedgerStore(db: LedgerDatabase) : LedgerStore {
|
class SqlLedgerStore(db: LedgerDatabase) : LedgerStore {
|
||||||
private val queries = db.ledgerQueries
|
private val queries = db.ledgerQueries
|
||||||
|
|||||||
Reference in new issue
Block a user