Closed vitaly72 closed 5 months ago
Hard to say much without seeing more code. Do you have a sample project? What platforms are you running on?
Project running on Android and iOS. it's DI Koin:
private val memoryModule = module {
singleOf(::Settings)
}
it's repository implementation
internal class NameLocalDataSource(
private val settings: Settings,
) {
fun save(name: Name) {
settings.encodeValue(
serializer = Name.serializer(),
key = "name",
value = name,
)
}
fun get(): Name = settings.decodeValue(
serializer = Name.serializer(),
key = "name",
defaultValue = emptyName(),
)
fun clear() {
settings.remove("name")
settings -= "name"
settings["name"] = null
}
private fun emptyName(): Name = Name(
first = "",
last = "",
)
}
If you're using serialization stuff you'll want removeValue()
instead of remove()
.
I use
multiplatform-settings-no-arg
in KMP project and I need to clear the values in the settings, none of these methods work