Commit f40e1aa 1 parent 785f0dd commit f40e1aa Copy full SHA for f40e1aa
File tree 6 files changed +15
-15
lines changed
6 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,6 @@ plugins {
6
6
alias(libs.plugins.nexusPublish)
7
7
}
8
8
9
- subprojects {
10
- group = " de.charlex.settings"
11
- version = " 2.0.0-alpha01"
12
- }
13
-
14
9
nexusPublishing {
15
10
repositories {
16
11
sonatype {
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ fun Screen() {
42
42
}) {
43
43
Text (" Set Name to UnknownName" )
44
44
}
45
+
46
+ Button ({
47
+ coroutineScope.launch {
48
+ dataStore.clear()
49
+ }
50
+ }) {
51
+ Text (" Clear DataStore" )
52
+ }
45
53
}
46
54
}
47
55
}
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ plugins {
3
3
}
4
4
5
5
group = " de.charlex.settings"
6
- version = " 2.0.0-alpha01 "
6
+ version = " 2.0.0-alpha02 "
7
7
description = " Kotlin Multiplatform Settings Datastore"
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ interface SettingsDataStore {
22
22
23
23
companion object {
24
24
25
- internal var settingsDataStore : SettingsDataStore ? = null
25
+ internal val settingsDataStoreMap : MutableMap < String , SettingsDataStore > = mutableMapOf ()
26
26
27
27
/* *
28
28
* When using with robolectric, please use
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package de.charlex.settings.datastore
2
2
3
3
import android.content.Context
4
4
import androidx.datastore.core.DataMigration
5
- import androidx.datastore.core.MultiProcessDataStoreFactory
6
5
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
7
6
import androidx.datastore.preferences.core.Preferences
8
7
import kotlinx.coroutines.CoroutineScope
@@ -17,8 +16,8 @@ fun SettingsDataStore.Companion.create(
17
16
scope : CoroutineScope = CoroutineScope (Dispatchers .IO + SupervisorJob ()),
18
17
// security: Security = AESSecurity
19
18
): SettingsDataStore {
20
- if (settingsDataStore == null ) {
21
- settingsDataStore = SettingsDataStoreImpl (
19
+ return settingsDataStoreMap.getOrPut(name ) {
20
+ SettingsDataStoreImpl (
22
21
dataStore = createDataStore(
23
22
migrations = migrations,
24
23
corruptionHandler = corruptionHandler,
@@ -29,6 +28,5 @@ fun SettingsDataStore.Companion.create(
29
28
// security = security
30
29
)
31
30
}
32
- return settingsDataStore!!
33
31
}
34
32
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ fun SettingsDataStore.Companion.create(
21
21
scope : CoroutineScope = CoroutineScope (Dispatchers .IO + SupervisorJob ()),
22
22
// security: Security = AESSecurity
23
23
): SettingsDataStore {
24
- if (settingsDataStore == null ) {
25
- settingsDataStore = SettingsDataStoreImpl (
24
+ return settingsDataStoreMap.getOrPut(name ) {
25
+ SettingsDataStoreImpl (
26
26
dataStore = createDataStore(
27
27
migrations = migrations,
28
28
corruptionHandler = corruptionHandler,
@@ -34,12 +34,11 @@ fun SettingsDataStore.Companion.create(
34
34
appropriateForURL = null ,
35
35
create = false ,
36
36
error = null ,
37
- )
37
+ )
38
38
requireNotNull(documentDirectory).path + " /$name "
39
39
}
40
40
// security = security
41
41
)
42
42
}
43
- return settingsDataStore!!
44
43
}
45
44
You can’t perform that action at this time.
0 commit comments