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

commonMain.pro.respawn.flowmvi.plugins.InitPlugin.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.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

/**
 * Installs a plugin that invokes [block] when [pro.respawn.flowmvi.api.Store.start] is called.
 * @see StorePlugin.onStart
 */
@FlowMVIDSL
public fun  StoreBuilder.init(
    block: suspend PipelineContext.() -> Unit
): Unit = install(initPlugin(block))

/**
 * Creates a plugin that invokes [block] after [pro.respawn.flowmvi.api.Store.start] is called.
 * @see StorePlugin.onStart
 */
@FlowMVIDSL
public fun  initPlugin(
    block: suspend PipelineContext.() -> Unit,
): StorePlugin = plugin { onStart(block) }