mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: modern APIs — Koin 4.2, CMP 1.11, Ktor resilience, Room @Upsert, injected dispatchers (#5119)
This commit is contained in:
parent
99378c9291
commit
9acdf5309f
32 changed files with 453 additions and 278 deletions
|
|
@ -50,7 +50,7 @@ class PreferencesDataStoreModule {
|
|||
@Named("CorePreferencesDataStore")
|
||||
fun providePreferencesDataStore(
|
||||
context: Context,
|
||||
@Named("DataStoreScope") scope: CoroutineScope,
|
||||
@Named(DATASTORE_SCOPE) scope: CoroutineScope,
|
||||
): DataStore<Preferences> = PreferenceDataStoreFactory.create(
|
||||
corruptionHandler = ReplaceFileCorruptionHandler(produceNewData = { emptyPreferences() }),
|
||||
migrations =
|
||||
|
|
@ -66,7 +66,7 @@ class LocalConfigDataStoreModule {
|
|||
@Named("CoreLocalConfigDataStore")
|
||||
fun provideLocalConfigDataStore(
|
||||
context: Context,
|
||||
@Named("DataStoreScope") scope: CoroutineScope,
|
||||
@Named(DATASTORE_SCOPE) scope: CoroutineScope,
|
||||
): DataStore<LocalConfig> = DataStoreFactory.create(
|
||||
storage =
|
||||
OkioStorage(
|
||||
|
|
@ -85,7 +85,7 @@ class ModuleConfigDataStoreModule {
|
|||
@Named("CoreModuleConfigDataStore")
|
||||
fun provideModuleConfigDataStore(
|
||||
context: Context,
|
||||
@Named("DataStoreScope") scope: CoroutineScope,
|
||||
@Named(DATASTORE_SCOPE) scope: CoroutineScope,
|
||||
): DataStore<LocalModuleConfig> = DataStoreFactory.create(
|
||||
storage =
|
||||
OkioStorage(
|
||||
|
|
@ -104,7 +104,7 @@ class ChannelSetDataStoreModule {
|
|||
@Named("CoreChannelSetDataStore")
|
||||
fun provideChannelSetDataStore(
|
||||
context: Context,
|
||||
@Named("DataStoreScope") scope: CoroutineScope,
|
||||
@Named(DATASTORE_SCOPE) scope: CoroutineScope,
|
||||
): DataStore<ChannelSet> = DataStoreFactory.create(
|
||||
storage =
|
||||
OkioStorage(
|
||||
|
|
@ -123,7 +123,7 @@ class LocalStatsDataStoreModule {
|
|||
@Named("CoreLocalStatsDataStore")
|
||||
fun provideLocalStatsDataStore(
|
||||
context: Context,
|
||||
@Named("DataStoreScope") scope: CoroutineScope,
|
||||
@Named(DATASTORE_SCOPE) scope: CoroutineScope,
|
||||
): DataStore<LocalStats> = DataStoreFactory.create(
|
||||
storage =
|
||||
OkioStorage(
|
||||
|
|
|
|||
|
|
@ -24,10 +24,17 @@ import org.koin.core.annotation.Named
|
|||
import org.koin.core.annotation.Single
|
||||
import org.meshtastic.core.common.util.ioDispatcher
|
||||
|
||||
/**
|
||||
* Koin qualifier for the application-scoped [CoroutineScope] shared by all [DataStore] instances.
|
||||
*
|
||||
* Used with `@Named(DATASTORE_SCOPE)` in Koin annotations and `named(DATASTORE_SCOPE)` in manual DSL modules.
|
||||
*/
|
||||
const val DATASTORE_SCOPE = "DataStoreScope"
|
||||
|
||||
@Module
|
||||
@ComponentScan("org.meshtastic.core.datastore")
|
||||
class CoreDatastoreModule {
|
||||
@Single
|
||||
@Named("DataStoreScope")
|
||||
@Named(DATASTORE_SCOPE)
|
||||
fun provideDataStoreScope(): CoroutineScope = CoroutineScope(ioDispatcher + SupervisorJob())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue