serializeStatePlugin

inline fun <T : S, S : MVIState, I : MVIIntent, A : MVIAction> serializeStatePlugin(path: String, serializer: KSerializer<T>, json: Json = DefaultJson, behaviors: Set<SaveBehavior> = SaveBehavior.Default, name: String? = serializer.descriptor.serialName.plus(PluginNameSuffix), context: CoroutineContext = Dispatchers.Default, resetOnException: Boolean = true, noinline recover: suspend (Exception) -> T? = ThrowRecover): LazyPlugin<S, I, A>

An overload of saveStatePlugin that is configured with some default values for convenience.

This overload will save a GZip-compressed JSON (if supported by the platform) of the state value of type T to a platform-dependent place. For example, on native platforms, a File specified by path. On browser platforms, to a local storage.

  • This will save the state according to the behaviors specified in SaveBehavior.Default.

  • By default, this will use Dispatchers.Default to save the state (context).

  • This will only compress the JSON if the platform permits it (Android, JVM). (CompressedFileSaver).

  • This will reset the state on exceptions in the store (resetOnException).

  • This will invoke recover if an exception is encountered when saving or restoring the state.

  • By default this will throw if the state cannot be read or saved (recover).

inline fun <T : S, S : MVIState, I : MVIIntent, A : MVIAction> serializeStatePlugin(dir: String, serializer: KSerializer<T>, json: Json = DefaultJson, behaviors: Set<SaveBehavior> = SaveBehavior.Default, filename: String = serializer.descriptor.serialName, fileExtension: String = ".json", context: CoroutineContext = Dispatchers.Default, resetOnException: Boolean = true, name: String? = "", noinline recover: suspend (Exception) -> T? = ThrowRecover): LazyPlugin<S, I, A>

Deprecated

Please use an overload that explicitly provides a full path

An overload of saveStatePlugin that is configured with some default values for convenience.

This overload will save a GZip-compressed JSON of the state value of type T to a file in the dir directory and named filename with a specified fileExtension.

  • This will save the state according to the behaviors specified in SaveBehavior.Default.

  • By default, this will use Dispatchers.Default to save the state (context).

  • This will only compress the JSON if the platform permits it (Android, JVM). (CompressedFileSaver).

  • This will reset the state on exceptions in the store (resetOnException).

  • This will invoke recover if an exception is encountered when saving or restoring the state.