Package-level declarations

Functions

Link copied to clipboard
inline fun <T> CallbackSaver(delegate: Saver<T>, crossinline onSave: suspend (T?) -> Unit = {}, crossinline onRestore: suspend (T?) -> Unit = {}): Saver<T>

A Saver implementation that adds additional behavior to the given delegate's Saver.save and Saver.restore methods.

Link copied to clipboard

A DefaultFileSaver implementation that saves a compressed String state to the file system. Usually used as a decorator for JsonSaver

Link copied to clipboard
inline fun <T> DefaultFileSaver(path: String, crossinline write: suspend (data: T?, toPath: String) -> Unit, crossinline read: suspend (fromPath: String) -> T?): Saver<T>

A Saver implementation that saves the given state to a file in a specified path

Link copied to clipboard

A DefaultFileSaver implementation that saves String state to the file system.

Link copied to clipboard
fun <T> JsonSaver(json: Json, serializer: KSerializer<T>, delegate: Saver<String>): Saver<T>
fun <T> JsonSaver(json: Json, serializer: KSerializer<T>, delegate: Saver<String>, recover: suspend (Exception) -> T?): Saver<T>

A Saver implementation that will transform the given state to a JSON string before passing it to the delegate. It will use the specified json instance and serializer to transform the state. By default it will recover by trying the delegates' recover first, but if deserialization fails, it will throw.

Link copied to clipboard
fun <T> LoggingSaver(delegate: Saver<T>, logger: StoreLogger, level: StoreLogLevel? = null, tag: String? = "Saver"): Saver<T>

A Saver that writes to logger during save restoration, saving and errors.

Link copied to clipboard
inline fun <T, R> MapSaver(delegate: Saver<R>, crossinline from: suspend (R) -> T?, crossinline to: suspend (T?) -> R?): Saver<T>

A Saver that maps the saved state to a value of T before passing it to the delegate.

Link copied to clipboard
fun <S> NoOpSaver(): Saver<S>

A Saver that will do nothing to save the state and will not Saver.restore to any state.

Link copied to clipboard
inline fun <T : Parcelable, MVIState> ParcelableSaver(handle: SavedStateHandle, key: String = key<T>()): <Error class: unknown class><T>

A Saver implementation that saves the given Parcelable state to a handle.

Link copied to clipboard
fun <T> RecoveringSaver(delegate: Saver<T>, recover: suspend (Exception) -> T?): Saver<T>

Saver that also catches exceptions during delegate's Saver.save and Saver.restore and handles them using recover.

Link copied to clipboard
fun <T> SavedStateHandleSaver(handle: SavedStateHandle, key: String): <Error class: unknown class><T>

A Saver implementation that saves the specified value of T to a handle. The type of T must be saveable in a bundle, or the framework code will throw. If your state is Parcelable, use the ParcelableSaver instead.

Link copied to clipboard
inline fun <T> Saver(crossinline save: suspend (T?) -> Unit, crossinline restore: suspend () -> T?): Saver<T>
inline fun <T> Saver(crossinline save: suspend (T?) -> Unit, crossinline restore: suspend () -> T?, crossinline recover: suspend (e: Exception) -> T?): Saver<T>

A Saver builder function

Link copied to clipboard
inline fun <T : S, S> TypedSaver(delegate: Saver<T>): Saver<S>

A MapSaver that will only persist values of type T.