Status Update
Comments
va...@google.com <va...@google.com> #2
For the KSerializer
to Saver
direction,
val <T : Any> KSerializer<T>.saver: Saver<T, SavedState> get() = Saver(
save = { encodeToSavedState(this@saver, it) },
restore = { decodeFromSavedState(this, it) },
)
is working well.
It would be great if this was provided somewhere in a library.
mg...@google.com <mg...@google.com> #3
We're focusing our support on KSerializer.toSaver()
. We won't be implementing Saver.toSerializer()
because KSerializer
works with any Encoder
/Decoder
and trying to use a Saver
to encode any other format besides SavedState
/Bundle
would be an error.
mg...@google.com <mg...@google.com> #4
We plan to introduce KSerializer.toSaver()
in androidx.compose.runtime.saveable
as an optional feature. We will include an dependency on KTX Serialization (if not used by clients, R8 will remove it) but will not depend on savedstate
, as the implementation here does not rely on any savedstate
-specific symbols.
mg...@google.com <mg...@google.com>
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
Author: Marcello Galhardo <
Link:
Expose SavedStateConfig
properties as public
Expand for full commit details
Expose `SavedStateConfig` properties as public
- We have cases where `SavedStateConfig` properties need to be used in other modules, such as handling fallbacks with `serializersModule.serializer()` to support contextual and polymorphic serializers.
- To follow KTX Serialization convention, we are keeping `SavedStateConfig` properties public, similar to how `JsonConfiguration` does.
RelNote: "`SavedStateConfig` properties are now public, enabling other modules to use these configurations."
Bug: 378897438
Test: N/A
Change-Id: Ie5f4997bc61932de390da3699339e01b2e91b514
Files:
- M
savedstate/savedstate/api/current.txt
- M
savedstate/savedstate/api/restricted_current.txt
- M
savedstate/savedstate/bcv/native/current.txt
- M
savedstate/savedstate/src/commonMain/kotlin/androidx/savedstate/serialization/SavedStateConfig.kt
Hash: ec92c9e6c519cd5c3b3ea54ea523e4b7dc2a15dc
Date: Tue Feb 18 14:27:58 2025
mg...@google.com <mg...@google.com>
mg...@google.com <mg...@google.com> #6
We’ve decided not to provide a public helper function for converting from Saver
to KSerializer
, as we’re planning to implement a rememberSaveable
function that accepts a KSerializer
(see rememberSaveable
variant.
(Please note that we introduced an internal helper function in rememberSaveable
variant.)
Description
While
saveable
depends on aSaver
implementation,saved
depends on aKSerializer
. Both are valid options, depending on project needs (e.g., adding a KotlinX Serialization dependency might be undesirable).To smooth the transition between these APIs, we want to enable using
Saver
as aKSerializer
and vice versa.This would allow using
Serializable
classes insaveable
, andSaveable
data insaved
.Since
Saver
returns a type accepted byBundle
, andencodeToSavedState
returns aBundle
, we can theoretically wrap one within the other for compatibility with both APIs at the cost of an wrapper instance.The goal is to determine the best way to handle this interoperability.