serializationSaver

@ExperimentalSerializationApi
inline fun <T> serializationSaver(key: AtomSaverKey, serializer: KSerializer<T> = serializer(), bundler: Bundler = Bundler): AtomSaver<T>

Create an AtomSaver for Kotlin Serialization.

Usage:

@Serializable
data class CounterData(
val value: Int = 0
)

@OptIn(ExperimentalSerializationApi::class)
private val counterAtom = atom(CounterData(), saver = serializationSaver("counter"))

Return

The AtomSaver for the value.

Parameters

T

The type of the value to save and restore.

key

The key to be used to save and restore the value.

serializer

The serializer to use for the value.

bundler

The bundler to encode and decode the value. Default is Bundler.