commonMain.pro.respawn.flowmvi.plugins.RecoverPlugin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-jvm Show documentation
Show all versions of core-jvm Show documentation
A Kotlin Multiplatform MVI library based on plugins that is simple, fast, powerful & flexible
package pro.respawn.flowmvi.plugins
import pro.respawn.flowmvi.api.FlowMVIDSL
import pro.respawn.flowmvi.api.MVIAction
import pro.respawn.flowmvi.api.MVIIntent
import pro.respawn.flowmvi.api.MVIState
import pro.respawn.flowmvi.api.PipelineContext
import pro.respawn.flowmvi.api.StorePlugin
import pro.respawn.flowmvi.dsl.StoreBuilder
import pro.respawn.flowmvi.dsl.plugin
public typealias Recover = suspend PipelineContext.(e: Exception) -> Exception?
/**
* Create and install a [recoverPlugin].
*/
@FlowMVIDSL
public fun StoreBuilder.recover(
name: String? = null,
recover: Recover,
): Unit = install(recoverPlugin(name, recover))
/**
* Create a plugin that simply invokes [StorePlugin.onException] and decides how to proceed accordingly.
* See the parent function for more information.
*/
@FlowMVIDSL
public fun recoverPlugin(
name: String? = null,
recover: Recover
): StorePlugin = plugin {
this.name = name
onException(recover)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy