All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.pro.respawn.flowmvi.plugins.ConsumeIntentsPlugin.kt Maven / Gradle / Ivy

Go to download

A Kotlin Multiplatform MVI library based on plugins that is simple, fast, powerful & flexible

There is a newer version: 3.0.0
Show newest version
package pro.respawn.flowmvi.plugins

import pro.respawn.flowmvi.api.MVIAction
import pro.respawn.flowmvi.api.MVIIntent
import pro.respawn.flowmvi.api.MVIState
import pro.respawn.flowmvi.api.StorePlugin
import pro.respawn.flowmvi.dsl.StoreBuilder

private const val ConsumeIntentsPluginName: String = "ConsumeIntents"

/**
 * Create a [StorePlugin] that simply consumes intents and does nothing with them.
 * This is useful when you are using [reducePlugin] with `consume = false`
 * You can add this to the end of your store declaration to consume the remaining unprocessed intents if you are
 * **sure** that you already handled all of them fully
 *
 * @see reducePlugin
 */
public fun  consumeIntentsPlugin(
    name: String = ConsumeIntentsPluginName,
): StorePlugin = reducePlugin(name = name, consume = true) { }

/**
 * Create and install a plugin that consumes intents and does nothing with them.
 *
 * This is useful when you are using [reducePlugin] with `consume = false`
 * You can add this to the end of your store declaration to consume the remaining unprocessed intents if you are
 * **sure** that you already handled all of them fully
 * @see consumeIntents
 * @see reduce
 */
public fun  StoreBuilder.consumeIntents(
    name: String = ConsumeIntentsPluginName,
): Unit = reduce(name = name, consume = true) { }