Skip to content

Commit

Permalink
Stabilising DataStoreHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Jul 8, 2023
1 parent 9087292 commit 8387880
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 76 deletions.
2 changes: 1 addition & 1 deletion jchucomponents-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-core"
version = "1.7.1"
version = "1.7.2"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jchucomponents-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-ktx"
version = "1.7.1"
version = "1.7.2"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jchucomponents-prefs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-prefs"
version = "1.7.1"
version = "1.7.2"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.LocalContext
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.doublePreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.floatPreferencesKey
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.jeluchu.prefs.extensions.empty
Expand Down Expand Up @@ -117,6 +123,13 @@ class DataStoreHelpers {
dataStore = context.defaultPreferencesDataStore
}

fun intPrefsKey(name: String) = intPreferencesKey(name)
fun floatPrefsKey(name: String) = floatPreferencesKey(name)
fun longPrefsKey(name: String) = longPreferencesKey(name)
fun doublePrefsKey(name: String) = doublePreferencesKey(name)
fun stringPrefsKey(name: String) = stringPreferencesKey(name)
fun booleanPrefsKey(name: String) = booleanPreferencesKey(name)

fun <T> DataStore<Preferences>.getValueSync(
key: Preferences.Key<T>
) = runBlocking { data.first() }[key]
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion jchucomponents-qr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-qr"
version = "1.7.1"
version = "1.7.2"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jchucomponents-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-ui"
version = "1.7.1"
version = "1.7.2"
}
}
}
Expand Down

0 comments on commit 8387880

Please sign in to comment.