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 = { }, crossinline onException: suspend (e: Exception) -> Unit = {}): Saver<T>

A Saver implementation that does nothing but invoke the given onSave, onRestore, onException callbacks when the state changes

Link copied to clipboard
fun CompressedFileSaver(path: String, recover: suspend (Exception) -> String? = ThrowRecover): Saver<String>

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

fun CompressedFileSaver(dir: String, fileName: String, recover: suspend (Exception) -> String? = ThrowRecover): Saver<String>

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?, crossinline recover: suspend (Exception) -> T?): Saver<T>

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

inline fun <T> DefaultFileSaver(dir: String, fileName: String, crossinline write: suspend (data: T?, to: Path) -> Unit, crossinline read: suspend (from: Path) -> T?, crossinline recover: suspend (Exception) -> T?): Saver<T>

A Saver implementation that saves the given state to a file in a specified dir and fileName.

Link copied to clipboard
fun FileSaver(path: String, recover: suspend (Exception) -> String? = ThrowRecover): Saver<String>

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

fun FileSaver(dir: String, fileName: String, recover: suspend (Exception) -> String? = ThrowRecover): Saver<String>

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>, recover: suspend (Exception) -> T? = { e -> // TODO: Compiler bug does not permit inlining this delegate.recover(e)?.let { json.decodeFromString(serializer, it) } }): 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>(), noinline recover: suspend (Exception) -> T? = ThrowRecover): <Error class: unknown class><T>

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

Link copied to clipboard
fun <T> SavedStateHandleSaver(handle: SavedStateHandle, key: String, recover: suspend (Exception) -> T? = ThrowRecover): <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?, crossinline recover: suspend (e: Exception) -> T? = { throw it }): 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.