Philip Dukhov
02/20/2025, 5:31 AMStateKeeper
`consume`/`register` methods could use the same technique (or have an overload) that Json.encodeToString
does, so we don't have to pass the serializer manually, with something like essentyJson.serializersModule.serializer()
?
I think I can use Json
instead of essentyJson
and do an extension on my end, as the lib doesn't and is not expected to modify the serializersModule
in the future, but it would be nicer to be shipped with the lib.Arkadii Ivanov
02/20/2025, 12:01 PMArkadii Ivanov
02/21/2025, 11:30 AM@Serializable
.
import com.arkivanov.essenty.statekeeper.StateKeeper
import kotlinx.serialization.serializer
inline fun <reified T : Any> StateKeeper.consume(key: String): T? =
consume(key = key, strategy = serializer<T>())
inline fun <reified T : Any> StateKeeper.register(key: String, noinline supplier: () -> T?) {
register(key = key, strategy = serializer<T>(), supplier = supplier)
}